Can you change a Dbgrid Col width
Printable View
Can you change a Dbgrid Col width
Hi, Scott! Merry Christmas.
At design time you can set columns width in Property Page, Layout Tab. If you don't want the user be able to change the size of column , uncheck AllowSizing.
At run time:
Dim Co As Column
Dim Co1 As Column
Set Co = DBGrid1.Columns(0)
Set Co1 = DBGrid1.Columns(1)
Co.Width = 1000
Co1.Width = 2000
Hope it will help you.
Larisa
Sorry LG but this did not change the Col Width
Try this:
DBGrid1.row = 1
DBGrid1.colwidth(0) = "2000"
This would set the col width of the first col, 2 row.
You can try this with dbgrid 5 or higher..
' item 0 is the first column
DBGrid1.Columns.Item(0).Width = 1000
No not yet. I not sure where ya'll came up with combination of property but they don't belong together.
lol, well you can't fault us for trying :-) What version of VB are you using? And which DBGrid? The one that ships with VB or a different one?
I just tried this and it worked fine:
grdSamples.ColWidth(0) = grdSamples.ColWidth(0) + 1000
I put this in a button and each time it would add 1000 to it. How does it not work on yours?
I thank you for your help. I am using VB5