Hi All,
I am trying to customise my columns on a datagrid. I have used code similar to this before, however my code is not altering the column widths.
Here is the code:
The datagrid populates from the dataset ds with no problems but the column names and column widths that I attempted to enforce have absolutely no effect.
Please help.
Thanks, Dave.
I am trying to customise my columns on a datagrid. I have used code similar to this before, however my code is not altering the column widths.
Here is the code:
Visual Basic:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim mydgTableStyle As New DataGridTableStyle
Dim mygrdColStyle1 As New DataGridTextBoxColumn
Dim mygrdColStyle2 As New DataGridTextBoxColumn
DataGrid1.TableStyles.Clear()
With mydgTableStyle
.MappingName = "ds.tables(0)"
End With
With mygrdColStyle1
.HeaderText = "Email Address"
.MappingName = "Email"
.Width = 400
End With
With mygrdColStyle2
.HeaderText = "Date Signed"
.MappingName = "DateSigned"
.Width = 60
End With
mydgTableStyle.GridColumnStyles.Add(mygrdColStyle1)
mydgTableStyle.GridColumnStyles.Add(mygrdColStyle2)
Try
DataGrid1.TableStyles.Add(mydgTableStyle)
DataGrid1.DataSource = ds.Tables(0)
Catch ex As Exception
End Try
End Sub
Please help.
Thanks, Dave.