|
-
Apr 8th, 2005, 12:27 AM
#1
Thread Starter
Frenzied Member
DataGrid Problem [URGENT]
Hello everybody,
I have a DataTable and I bind the DataTable with DataGrid. It shows all the columns with equal width. In these columns, I have a description field which contains large data. I need to increase width of this particular column of DataGrid.
Thanks.
-
Apr 8th, 2005, 04:45 AM
#2
Hyperactive Member
Re: DataGrid Problem [URGENT]
you can have a table mappings here, like this sample:
VB Code:
private void Form1_Load(object sender, System.EventArgs e)
{
//conn is a connection from sql
//DataAdapter da
DataTable dt = new DataTable();
da.SelectCommand=new SqlCommand("select * from Products",conn);
da.Fill(dt);
this.dataGrid1.DataSource=dt;
DataGridTableStyle dgt = new DataGridTableStyle();
dgt.MappingName=dt.TableName;
DataGridTextBoxColumn dgtbc = new DataGridTextBoxColumn();
dgtbc.MappingName=dt.Columns[0].ColumnName;
dgtbc.HeaderText = "ID"; // Product ID
dgtbc.Width=50;
DataGridTextBoxColumn dgtbc1 = new DataGridTextBoxColumn();
dgtbc1.MappingName=dt.Columns[1].ColumnName;
dgtbc1.HeaderText = "Description"; // description
dgtbc1.Width=200;
dgt.GridColumnStyles.AddRange(new DataGridTextBoxColumn[] {dgtbc,dgtbc1});
this.dataGrid1.TableStyles.Add(dgt);
}
you can also add some other columns depends on your stuff to view.
-
Apr 12th, 2005, 01:24 AM
#3
Member
Re: DataGrid Problem [URGENT]
Go to the property builder of you datagrid (in design mode), next select format. Then you select your column and there you can fill in the width.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|