Click to See Complete Forum and Search --> : Column width in Datagrid - units of measurement?
billwagnon
Nov 8th, 1999, 08:11 AM
I have a Datagrid with four columns. Two of the columns can be turned off (set to zero width). This works great :)!
I want to set the columns so they aren't in total any wider than the datagrid width. So what I did was set three of the widths, then set the fourth one equal to the datagrid width, minus the widths of the other three. Good in theory, but it doesn't work :(. Are the columns and datagrid measured differently?
Thank you in advance for your help!
billwagnon
Nov 9th, 1999, 12:57 AM
anyone? anyone? Bueller?
MartinLiss
Nov 9th, 1999, 01:02 AM
What you described you did should work. Post your code or email me and I'll take a look at it.
------------------
Marty
billwagnon
Nov 9th, 1999, 01:08 PM
Here it is Marty - thank you!
Set dgPlanBox3.DataSource = ThirdRsGrid
With dgPlanBox3
.Columns(2).Width = 0 'mgr name
.Columns(3).Width = 0 'mgr name
.Columns(1).Width = .Width - .Columns(0).Width ' - .Columns(1).Width
End With
With dgPlanBox3 'plan name column minus the other widths
dgPlanBox3.Columns(1).Width = .Width - .Columns(0).Width - .Columns(2).Width - .Columns(3).Width
End With
wallacejww
Nov 11th, 2003, 05:26 PM
You might want to try this
'---------------------------
dim iWidth as Integer
'Set first two columns
dgPlanBox3.Columns(0).Width = 0
dgPlanBox3.Columns(1).Width = 0
'set an integer to the caculated remaing width this will round to a whole number
iWidth = dgPlanBox3.Width - (dgPlanBox3.Columns(0).Width + dgPlanBox3.Columns(1).Width)
'set your third column to the remainder
dgPlanBox3.Columns(2).Width = iWidth
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.