DataGridColumnStyles issue

J

jvb

Hey all,

I am getting this message when trying to view data in my datagrid:

....DataGridColumnStyle cannot be used because it is not associated with
a Property or Column in the DataSource.

Here is the skinny...

1. The tablestyle that it is puking on is a manually created table in
code.
2. The tablestyle will display correctly in the grid if it is set as
the direct datasourece and not
as a child table.
3. If i do not apply the tablestyle to the grid for this table, the
relation will display correctly.

The form operates correctly until I try to expand the grid.

Any thoughts?

Here is the code that creates the table and the table styles. The
Customers table is populated via a SQL query.

Private Function CreateOrderTable(ByVal TableName As String) As
DataTable

Dim ReturnTable As New DataTable(TableName)

ReturnTable.Columns.Add(New DataColumn("order_id",
GetType(System.Int32)))
ReturnTable.Columns.Add(New DataColumn("customer_id",
GetType(System.Int32)))
ReturnTable.Columns.Add(New DataColumn("order_number",
GetType(System.Int32)))
ReturnTable.Columns.Add(New DataColumn("order_quantity",
GetType(System.Int32)))
ReturnTable.Columns.Add(New DataColumn("order_date",
GetType(System.DateTime)))
ReturnTable.Columns.Add(New DataColumn("ship_date",
GetType(System.DateTime)))

ReturnTable.Columns("trade_id").ColumnMapping =
MappingType.Hidden

ReturnTable.Columns("order_date").DefaultValue =
Me.dtpOrderDate.Value
ReturnTable.Columns("ship_date").DefaultValue =
Me.dtpShipDate.Value

Return ReturnTable

End Function

Private Function CreateOrderTableStyle(ByVal MappingName As String) As
DataGridTableStyle
Dim ReturnStyle As New DataGridTableStyle

ReturnStyle.MappingName = MappingName


ReturnStyle.GridColumnStyles.Add(CustomControls.CommonInteraction.CreateTextBoxColumn("order_quantity",
"Quantity", 100))

ReturnStyle.GridColumnStyles.Add(CustomControls.CommonInteraction.CreateTextBoxColumn("order_number",
"Order Number", 100))

ReturnStyle.GridColumnStyles.Add(CustomControls.CommonInteraction.CreateTextBoxColumn("order_date",
"Order Date", 100, "d"))

ReturnStyle.GridColumnStyles.Add(CustomControls.CommonInteraction.CreateTextBoxColumn("ship_date",
"Ship Date", 100, "d"))

Return ReturnStyle

End Function

Private Sub ShowTime()

Me.dgSales.DataSource = Me.SalesDataSet

Me.dgSales.TableStyles.Add(Me.CreateSalesTableStyle("Customers"))

Me.dgSales.TableStyles.Add(Me.CreateManualSalesTableStyle("Orders"))

End Sub


Thanks,

jvb
 
J

jvb

NVM, i figured out my issue. I was giving the MappingName the name of
the table, not the name of the relation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top