Home › Forums › WinForms controls › Xceed Grid for WinForms › Detail Grid Not showing added columns
-
AuthorPosts
-
#13053 |
Let me start off by saying that I’ve already emailed support for this but I wanted to get any opinions on how best to implement this. I want to allow users to add columns to the grid at will. It works great for the grid datarows…but it seems that the detail grids are not showing the added columns even after calling .UpdateDetailGrids…Has anyone else had this problem?
Here’s the code I wrote:
Public Sub addChangeColumnToGrid(ByRef thisGrid As Xceed.Grid.DetailGrid, ByVal targetColumn As String, ByVal newColumn As String)
Dim thisRow As System.Data.DataRow
Dim thisCol As Xceed.Grid.Column
Dim fromCol As Xceed.Grid.Column
Dim thisfundCol As Xceed.Grid.Column
Dim colCounter As Integer = 0thisCol = New Column(newColumn, GetType(Double))
thisCol.Title = “Change”
thisCol.ReadOnly = True
thisCol.FormatProvider = New ChangeStringFormatter‘add the column in to the main grid
For colCounter = 0 To thisGrid.Columns.Count – 1
If Convert.ToBoolean(InStr(thisGrid.Columns(colCounter).FieldName.ToLower, targetColumn)) Then
Try
thisGrid.Columns.Insert(colCounter + 1, thisCol)
Catch Err As Exception
myDebugLog.CatchError(Err, “Could not add new column to grid?”)
End Try
Exit For
End If
Next
End SubThanks
Imported from legacy forums. Posted by Papo (had 2585 views)
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.comdtGridTable.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.NonedataRelation = 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))
NextFor 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
NextdgStockRotation.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 = TruedgStockRotation.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)
Hi,
This code can help you.
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.NonedataRelation = 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))
NextFor 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
NextdgStockRotation.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 = TruedgStockRotation.UpdateDetailGrids()
// First end the detaled grid inintialise and then master grid
dgChildTable.EndInit()dgStockRotation.EndInit()
Imported from legacy forums. Posted by Sivaram (had 3650 views)
-
AuthorPosts
- You must be logged in to reply to this topic.