J
Jeff Molby
This is frustrating me. I have to create a new table at runtime, and
I'm able to, but it doesn't appear. The datagrid always shows the default
tablestyle, no matter what I do. Here's my code.
<Snip>
Dim col As Windows.Forms.DataGridColumnStyle
Dim ts As New Windows.Forms.DataGridTableStyle
'Creates by Business Object
dcTaxTypes = New InventoryBO.ProductTaxTypes
dcTaxTypes.ConnectionString = CONNECT_STRING
dcTaxTypes.SelectFilter =
InventoryDC.ProductTaxTypesDC.SelectFilters.ListBox
dcTaxTypes.OrderByFilter =
InventoryDC.ProductTaxTypesDC.OrderByFilters.Description
dcTaxTypes.Open()
ts.MappingName = GetMappingName(dcTaxTypes.DataSet.Tables(0)) ' Sets the
Mapping Name
col = New Windows.Forms.DataGridTextBoxColumn
col.MappingName = "ProductID"
col.Width = 100
col.HeaderText = "ID"
ts.GridColumnStyles.Add(col)
col = New Windows.Forms.DataGridTextBoxColumn
col.MappingName = "TaxAmount"
col.Width = 100
col.HeaderText = "Amount"
ts.GridColumnStyles.Add(col)
Me.DataGrid1.TableStyles.Clear()
Me.DataGrid1.TableStyles.Add(ts)
Me.DataGrid1.DataSource = dcDetails
Me.DataGrid1.Refresh()
</Snip>
This code executes without throwing any errors, but it does absolutely
nothing to my datagrid. It shows all 4 of the columns that the default
tablestyle has, rather than just the two columns that the new tablestyle
has.
You're a hero if you can help me!
Jeff
I'm able to, but it doesn't appear. The datagrid always shows the default
tablestyle, no matter what I do. Here's my code.
<Snip>
Dim col As Windows.Forms.DataGridColumnStyle
Dim ts As New Windows.Forms.DataGridTableStyle
'Creates by Business Object
dcTaxTypes = New InventoryBO.ProductTaxTypes
dcTaxTypes.ConnectionString = CONNECT_STRING
dcTaxTypes.SelectFilter =
InventoryDC.ProductTaxTypesDC.SelectFilters.ListBox
dcTaxTypes.OrderByFilter =
InventoryDC.ProductTaxTypesDC.OrderByFilters.Description
dcTaxTypes.Open()
ts.MappingName = GetMappingName(dcTaxTypes.DataSet.Tables(0)) ' Sets the
Mapping Name
col = New Windows.Forms.DataGridTextBoxColumn
col.MappingName = "ProductID"
col.Width = 100
col.HeaderText = "ID"
ts.GridColumnStyles.Add(col)
col = New Windows.Forms.DataGridTextBoxColumn
col.MappingName = "TaxAmount"
col.Width = 100
col.HeaderText = "Amount"
ts.GridColumnStyles.Add(col)
Me.DataGrid1.TableStyles.Clear()
Me.DataGrid1.TableStyles.Add(ts)
Me.DataGrid1.DataSource = dcDetails
Me.DataGrid1.Refresh()
</Snip>
This code executes without throwing any errors, but it does absolutely
nothing to my datagrid. It shows all 4 of the columns that the default
tablestyle has, rather than just the two columns that the new tablestyle
has.
You're a hero if you can help me!
Jeff