sanders720
Programmer
I have a question about column styles and mapping using VB.NET. I think I've setup the column styles okay, but columns themselves are not mapped.
First, I define the column styles...
Public Sub PopulateDataGrid1_DefineColumns()
' Define Table
' Part Qty
Dim aCol0 As New DataGridTextBoxColumn
With aCol0
.MappingName = "QTY"
.HeaderText = "Quantity"
.Width = 6
End With
' Sub Assembly
Dim aCol07 As New DataGridTextBoxColumn
With aCol07
.MappingName = "SUBA"
.HeaderText = "SubLevel"
.Width = 20
End With
.
.
.
Then I add the columns...
' Add Columns
With aPartTableStyle.GridColumnStyles
.Add(aCol0)
.Add(aCol07)
.
.
.
Then I define the specific per column data for the row...
Public Sub PopulateDataGrid1_DefineRows()
' Define Column Data
' Map Part Table Style
aPartTableStyle.MappingName = "Parts"
' Quantity
Q = Q
' Sub Assembly
SUBA = SUBA
.
.
.
' Bind the Datatable to the Datagrid
DataGrid1.DataSource = aPartsTable
DataGrid1.AllowSorting = True
Then I add the rows. Tis is where the error shows up...
' Add Rows
Dim aRow As DataRow
aRow = aPartsTable.NewRow()
aRow("QTY") = Q '<---ERROR Column QTY does not belong to the table
aRow("SUBA") = SUBA
First, I define the column styles...
Public Sub PopulateDataGrid1_DefineColumns()
' Define Table
' Part Qty
Dim aCol0 As New DataGridTextBoxColumn
With aCol0
.MappingName = "QTY"
.HeaderText = "Quantity"
.Width = 6
End With
' Sub Assembly
Dim aCol07 As New DataGridTextBoxColumn
With aCol07
.MappingName = "SUBA"
.HeaderText = "SubLevel"
.Width = 20
End With
.
.
.
Then I add the columns...
' Add Columns
With aPartTableStyle.GridColumnStyles
.Add(aCol0)
.Add(aCol07)
.
.
.
Then I define the specific per column data for the row...
Public Sub PopulateDataGrid1_DefineRows()
' Define Column Data
' Map Part Table Style
aPartTableStyle.MappingName = "Parts"
' Quantity
Q = Q
' Sub Assembly
SUBA = SUBA
.
.
.
' Bind the Datatable to the Datagrid
DataGrid1.DataSource = aPartsTable
DataGrid1.AllowSorting = True
Then I add the rows. Tis is where the error shows up...
' Add Rows
Dim aRow As DataRow
aRow = aPartsTable.NewRow()
aRow("QTY") = Q '<---ERROR Column QTY does not belong to the table
aRow("SUBA") = SUBA