Home Forums WinForms controls Xceed Grid for WinForms Detail Grid Not showing added columns Reply To: Detail Grid Not showing added columns

User (Old forums)
Member
Post count: 23064

Hi,

This code can help you.
I got one more example also. If you are not able to solve your proble you can contact my by sivaram_ks@sourcecodeintl.com

dtGridTable.PrimaryKey = New DataColumn() {dtGridTable.Columns(“ProductId”)}
dtChildGridTable.PrimaryKey = New DataColumn() {dtChildGridTable.Columns(“ProductId”),
dtChildGridTable.Columns(“Type/StoreQty”)}

‘**************** Realtion creation
dtGridTable.TableName = “StockRotationAlg”
dtChildGridTable.TableName = “ChildTable”

srDataSet.Tables.Add(dtGridTable)
srDataSet.Tables.Add(dtChildGridTable)

ParentColumn = dtGridTable.Columns(“ProductId”)
ChildColumn = dtChildGridTable.Columns(“ProductId”)

FKC = New ForeignKeyConstraint(“StockRotationAlgFKC”, ParentColumn, ChildColumn)
dtChildGridTable.Constraints.Add(FKC)
FKC.DeleteRule = Rule.Cascade
FKC.UpdateRule = Rule.Cascade
FKC.AcceptRejectRule = AcceptRejectRule.None

dataRelation = New dataRelation(“StockRotationAlgFKC”, ParentColumn, ChildColumn, False)

srDataSet.Relations.Add(dataRelation)

//////////////////////////////////////////////////////////////////////////////////////////////////
////// the following code should be in between “Begininit” and “Endinit” of
////// both master grid and the detailed grid.
//////////////////////////////////////////////////////////////////////////////////////////////////

dgStockRotation.BeginInit()
dgChildTable.BeginInit()

For intRow = 0 To dtGridTable.Columns.Count – 1
dgStockRotation.Columns.Add(New
Xceed.Grid.Column(dtGridTable.Columns(intRow).ColumnName,
dtGridTable.Columns(intRow).DataType))
Next

For intRow = 0 To dtChildGridTable.Columns.Count – 1
dgChildTable.Columns.Add(New
Xceed.Grid.Column(dtChildGridTable.Columns(intRow).ColumnName,
dtChildGridTable.Columns(intRow).DataType))
If intRow >= 2 Then
Me.dgChildTable.Columns(dtChildGridTable.Columns(intRow).
ColumnName).Width = 30
End If
Next

dgStockRotation.DetailGridTemplates.Clear()
dgStockRotation.Clear()
dgStockRotation.AllowDrop = False
dgStockRotation.DataSource = srDataSet
dgStockRotation.DataMember = “StockRotationAlg”

Dim colManagerRow As New Xceed.Grid.ColumnManagerRow()
dgStockRotation.HeaderRows.Add(colManagerRow)
dgChildTable.Clear()
dgChildTable.Collapsed = True
dgChildTable.DataSource = srDataSet
dgChildTable.DataMember = “StockRotationAlg.StockRotationAlgFKC”

dgStockRotation.DetailGridTemplates.Add(dgChildTable)
dgStockRotation.ShowTreeLines = True

dgStockRotation.UpdateDetailGrids()

// First end the detaled grid inintialise and then master grid
dgChildTable.EndInit()

dgStockRotation.EndInit()

If any problem feel free to contact me at any time.

Imported from legacy forums. Posted by Sivaram (had 252 views)