My columns in dataGridView3 are generated on the fly from a Select
statement, so I can't set up any columns properties before it is
created. Sort of the way I make them visible or not like the
following:
this.dataGridView3.Columns[0].Visible = false; //id
this.dataGridView3.Columns[1].Visible = false; //parent_id
How can I set the width of Columns[3]?
Any help is appreciated.
Thanks,
Trint
Nicholas Paldino [.NET/C# MVP] - 31 May 2007 14:38 GMT
Trint,
Why not just set the Width property on the DataGridViewColumn returned
from the indexer call to Columns? You are already using the Visible
property, if it is visible, then just set the width:
this.dataGridView3.Columns[3].Visible = true;
this.dataGridView3.Columns[3].Width = <your width here>;

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> My columns in dataGridView3 are generated on the fly from a Select
> statement, so I can't set up any columns properties before it is
[quoted text clipped - 7 lines]
> Thanks,
> Trint
-pb- - 31 May 2007 14:45 GMT
> My columns in dataGridView3 are generated on the fly from a Select
> statement, so I can't set up any columns properties before it is
[quoted text clipped - 7 lines]
> Thanks,
> Trint
Register for an event called RowDataBound of the grid and in that
event try setting the width of the desired column using
GridViewRowEventArgs event argument.
e.g. e.Row.Cells[0].Width = 100.
trint - 31 May 2007 16:45 GMT
> > My columns in dataGridView3 are generated on the fly from a Select
> > statement, so I can't set up any columns properties before it is
[quoted text clipped - 13 lines]
>
> e.g. e.Row.Cells[0].Width = 100.
Thanks Nicholas... this worked:
this.dataGridView3.Columns[3].Width = <your width here>;
Trint