Home Forums WinForms controls Xceed Grid for WinForms Problem with databinding !!

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #12999 |

    Hi all,
    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
    With grd
    .Dock = DockStyle.Fill
    .ReadOnly = True
    .Visible = True
    .FixedHeaderRows.Clear()
    .FixedFooterRows.Clear()
    .Columns.Clear()

    Dim groupByRow As groupByRow = New groupByRow
    ‘ The following line adds the group-by row to the grid’s fixed header rows.
    .FixedHeaderRows.Add(groupByRow)

    ‘ 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.
    .FixedHeaderRows.Add(columnManagerRow)

    RemoveHandler grd.AddingDataRow, AddressOf OnAddingDataRow
    AddHandler grd.AddingDataRow, AddressOf OnAddingDataRow

    ‘-NOTE : I TRIED USING BOTH METHODS OF BINDING…STILL DOESN’T WORK

    ‘grd.SetDataBinding(data, data.LoadQueue.TableName)
    grd.DataSource = data.LoadQueue

    For Each col As Xceed.Grid.Column In grd.Columns
    col.Visible = False
    Next

    ‘- 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

    With grd
    .Columns(“JobId”).Visible = True
    .Columns(“JobId”).Title = “#”
    .Columns(“JobId”).Width = 30
    End With

    End With

    End Sub

    ‘————————————–

    Has anyone encountered this behaviour before.
    Please help

    Cheers,

    Imported from legacy forums. Posted by Sharad (had 3759 views)

    User (Old forums)
    Member
    Post 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)
    Member
    Post 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.BeginInit()
    TransactionSummaryGrid.HeaderRows.Add(New Xceed.Grid.ColumnManagerRow)
    TransactionSummaryGrid.DataSource = Swag
    TransactionSummaryGrid.DataMember = “Account”
    TransactionSummaryGrid.DetailGridTemplates.Add(TransactionDetailGrid)
    TransactionDetailGrid.DataSource = Nothing
    TransactionDetailGrid.DataMember = “AccountTransactions”
    TransactionDetailGrid.HeaderRows.Add(New Xceed.Grid.ColumnManagerRow)

    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)
    Member
    Post 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?

    Thanks,

    Kapil

    Imported from legacy forums. Posted by kapilkelaiya (had 4253 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.