User (Old forums)MemberApril 5, 2004 at 4:58 amPost count: 23064
I have a form where i need to create grids dynamically depending upon user configuration. I have a panel control. I create the grid at run-time and add it to the panel control. I have a sub routine to initialize the grid, this sub accepts a reference to the grid and a reference to the dataset to bind to. This sub-routine works fine except for the columns hiding. I need to make few column visible=false after the databinding, but after the data is bound the grid’s columns.count still returns 0. Below is the procedure i use —
Private Sub InitGrid(ByRef grd As GridControl, ByRef data As LoadQueueDataSet)
‘- Initialize the Consignee Grid
.Dock = DockStyle.Fill
.ReadOnly = True
.Visible = True
Dim groupByRow As groupByRow = New groupByRow
‘ The following line adds the group-by row to the grid’s fixed header rows.
‘ The following line creates a column manager row used to manage the columns in
‘ the grid.
Dim columnManagerRow As columnManagerRow = New columnManagerRow
‘ The following line adds the column manager row to the grid’s fixed header rows.
RemoveHandler grd.AddingDataRow, AddressOf OnAddingDataRow
AddHandler grd.AddingDataRow, AddressOf OnAddingDataRow
‘-NOTE : I TRIED USING BOTH METHODS OF BINDING…STILL DOESN’T WORK
grd.DataSource = data.LoadQueue
For Each col As Xceed.Grid.Column In grd.Columns
col.Visible = False
‘- THIS CODE IS A WORKAROUND …ELSE THE NEXT CODE GENERATES AN ERROR ..THE COUNT RETURNS 0..BUT WHEN THE FORM IS DISPLAYED IT DISPLAYS ALL THE COLUMNS FROM THE DATASET
If grd.Columns.Count = 0 Then Exit Sub
.Columns(“JobId”).Visible = True
.Columns(“JobId”).Title = “#”
.Columns(“JobId”).Width = 30
Has anyone encountered this behaviour before.
Imported from legacy forums. Posted by Sharad (had 3759 views)User (Old forums)MemberApril 19, 2004 at 4:04 amPost count: 23064
After <i>grd.DataSource = data.LoadQueue</i> set the <b>BindingContext</b>-property to a new BindingContext:<code>grd.<b>BindingContext</b> = New <b>BindingContext</b></code>
Imported from legacy forums. Posted by Tommy (had 222 views)User (Old forums)MemberSeptember 3, 2004 at 3:27 pmPost count: 23064
This seems to work perfectly for a GridControl, though I am not sure quite why this is necessary. INcidentally, if you break to debug after setting the binding and wait about 10 seconds, the columns magically appear!
However, I am having the same issue with a DetailGrid, which in and of itself does not have a BindingContext property. Trying:
Dim TransactionSummaryGrid As New Xceed.Grid.GridControl
Dim TransactionDetailGrid As New Xceed.Grid.DetailGrid
TransactionSummaryGrid.DataSource = Swag
TransactionSummaryGrid.DataMember = “Account”
TransactionDetailGrid.DataSource = Nothing
TransactionDetailGrid.DataMember = “AccountTransactions”
TransactionDetailGrid.GridControl.BindingContext = New BindingContext
TransactionSummaryGrid.BindingContext = New BindingContext
Doesn’t do it – any thoughts?
The documentation for this grid is quite weak, it’s a bit frustating dealing with it.
Imported from legacy forums. Posted by JimIdle (had 312 views)User (Old forums)MemberOctober 3, 2005 at 11:48 pmPost count: 23064
I am facing the same problem.
After creating detail grid and binding it to datasrouce, column.count is always zero.
Is there anyway to “Refresh” or provide “BindingContext” for detailGrid as well?
Imported from legacy forums. Posted by kapilkelaiya (had 4253 views)
- You must be logged in to reply to this topic.