J
Jeff
I am stuck on trying to generate two columns headers for a datagrid on
form load. I can use a datatable as the datasource and get the results
I want, but I want to set different column widths and don't see a way
to do this through the datagrid properties. I am not using a database
connection, I just want to set column headers on the datagrid. I am
somewhat new to vb.net. Here is the code I am using. This code works
when the tableStyle.MappingName = an actual table in a database, but
not a datatable in a dataset without a database.
'Create DataGridTableStyle
Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = Me.DataSet1.Tables(0).TableName
'Create DataGridColumnStyle for each column
Dim column As New DataGridTextBoxColumn
column.MappingName = "Names"
column.MappingName = Me.DataSet1.Tables(0).Columns(0).ColumnName
column.HeaderText = "Names" column.Width = 100
tableStyle.GridColumnStyles.Add(column)
column = New DataGridTextBoxColumn
column.MappingName = "Description"
column.MappingName = Me.DataSet1.Tables(0).Columns(1).ColumnName
column.HeaderText = "Description"
column.Width = 250
tableStyle.GridColumnStyles.Add(column)
'Add tableStyle to datagrid
Me.DataGrid1.TableStyles.Clear()
Me.DataGrid1.TableStyles.Add(tableStyle)
What I am trying to do is create a datagrid that I can populate with
Active Directory users and descriptions. Maybe I am not going about it
the right way with a datagrid. If this will not work can someone give
me advice on what I should be using?
Thanks,
Jeff
form load. I can use a datatable as the datasource and get the results
I want, but I want to set different column widths and don't see a way
to do this through the datagrid properties. I am not using a database
connection, I just want to set column headers on the datagrid. I am
somewhat new to vb.net. Here is the code I am using. This code works
when the tableStyle.MappingName = an actual table in a database, but
not a datatable in a dataset without a database.
'Create DataGridTableStyle
Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = Me.DataSet1.Tables(0).TableName
'Create DataGridColumnStyle for each column
Dim column As New DataGridTextBoxColumn
column.MappingName = "Names"
column.MappingName = Me.DataSet1.Tables(0).Columns(0).ColumnName
column.HeaderText = "Names" column.Width = 100
tableStyle.GridColumnStyles.Add(column)
column = New DataGridTextBoxColumn
column.MappingName = "Description"
column.MappingName = Me.DataSet1.Tables(0).Columns(1).ColumnName
column.HeaderText = "Description"
column.Width = 250
tableStyle.GridColumnStyles.Add(column)
'Add tableStyle to datagrid
Me.DataGrid1.TableStyles.Clear()
Me.DataGrid1.TableStyles.Add(tableStyle)
What I am trying to do is create a datagrid that I can populate with
Active Directory users and descriptions. Maybe I am not going about it
the right way with a datagrid. If this will not work can someone give
me advice on what I should be using?
Thanks,
Jeff