D
Doug Bell
Hi,
How can I determine the number of columns in a DataGrid?
What I am trying to do is to build a function that will resize the last
column to fill the remaining space in the DataGrid.
Something like:?
Dim intCols As Integer = DataGrid1.DataSource.Columns.Count
Dim intUsedWidth as Integer=0
Dim i as Integer = 0
Dim intTargetWidth as Integer = DataGrid1.Width
For Each ctrl AS Control In Me.DataGrid1
If TypeOf ctrl Is VScrollBar then
If ctrl.Visible then
intTargetWidth =intTargetWidth - ctrl.Width
EndIf
EndIf
Next
Do While i< intCols
intUsedWidth=intUsedWidth +
DataGrid1.TableStyles(st).GridColumnStyles(i).Width
i=i+1
loop
If intUsedWidth<intTargetWidth then
DataGrid1.TableStyles(st).GridColumnStyles(i).Width=intTargetWidth -
intUsedWidth
endif
Thanks
Doug
How can I determine the number of columns in a DataGrid?
What I am trying to do is to build a function that will resize the last
column to fill the remaining space in the DataGrid.
Something like:?
Dim intCols As Integer = DataGrid1.DataSource.Columns.Count
Dim intUsedWidth as Integer=0
Dim i as Integer = 0
Dim intTargetWidth as Integer = DataGrid1.Width
For Each ctrl AS Control In Me.DataGrid1
If TypeOf ctrl Is VScrollBar then
If ctrl.Visible then
intTargetWidth =intTargetWidth - ctrl.Width
EndIf
EndIf
Next
Do While i< intCols
intUsedWidth=intUsedWidth +
DataGrid1.TableStyles(st).GridColumnStyles(i).Width
i=i+1
loop
If intUsedWidth<intTargetWidth then
DataGrid1.TableStyles(st).GridColumnStyles(i).Width=intTargetWidth -
intUsedWidth
endif
Thanks
Doug