Click to See Complete Forum and Search --> : Changing Dbgrid Col width
ScottF
Dec 25th, 1999, 12:52 AM
Can you change a Dbgrid Col width
LG
Dec 25th, 1999, 06:48 AM
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
ScottF
Jan 17th, 2000, 08:39 PM
Sorry LG but this did not change the Col Width
netSurfer
Jan 17th, 2000, 10:23 PM
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
ScottF
Jan 18th, 2000, 02:26 AM
No not yet. I not sure where ya'll came up with combination of property but they don't belong together.
netSurfer
Jan 18th, 2000, 02:35 AM
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?
netSurfer
Jan 18th, 2000, 02:39 AM
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?
ScottF
Jan 18th, 2000, 10:58 AM
I thank you for your help. I am using VB5
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.