This is a simple example of how to dynamically set the column width in a DataGrid control. I spent hours trying to find something that seemed to me should have been a simple help example. I hope I can save somebody some time.
Submitted On | |
By | Mike M. Mitchell |
Level | Beginner |
User Rating | 4.1 (58 globes from 14 users) |
Compatibility | VB.NET |
Category | Algorithims |
World | .Net (C#, VB.net) |
Archive File |
Dim myGridTableStyle As DataGridTableStyle = New DataGridTableStyle()
'Map the style to the dataset table. In this case I only use one table
' in my query.
myGridTableStyle.MappingName = "Insured"
grdQuotes.TableStyles.Add(myGridTableStyle)
myGridTableStyle.GridColumnStyles(0).Width = 0
myGridTableStyle.GridColumnStyles(1).Width = 250
myGridTableStyle.GridColumnStyles(2).Width = 250