How do I set width for each column individually of datagrid control? I already created a datatable as a source of the datagrid and created columns and rows into it.
Here's an example:
Here's an example:
VB.NET:
'Create columns
Dim dataTable As DataTable = New DataTable
dataTable.Rows.Clear()
dataTable.Columns.Clear()
dataColumn = New DataColumn(5) {}
For i = 0 To 4
dataColumn(i) = New DataColumn
dataColumn(i).DataType = System.Type.GetType("System.String")
dataColumn(i).ColumnName = i.ToString
Next i
dataTable.Columns.AddRange(dataColumn)
'Create rows
rowCount = 5
For i = 0 To r4
Dim rowArr As Object() = New Object(0) {}
dataTable.Rows.Add(rowArr)
Next i
'Bring data to the datatable
For i = 0 To 4
dataTable.Rows(rowCounter)(i) = i.ToString
index = index + 1
Next i
'Create datagrid
Dim myGrid As New myDataGrid
myGrid.DataSource = dataTable