Home Forums WinForms controls Xceed Grid for WinForms DataBind Issue?

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

    My program throws the following error when trying to add a Title to a GridColumn:

    System.ArgumentOutOfRangeException: The index must be greater than or equal to 0 and less than Count. Parameter name: index

    Inside the Debug Watch Pane, it shows the column count of the grid is 0:

    grid.Columns.Count = 0 

     

    Here is my code:

     

    Private

    Sub buildGrid(ByRef grid As Xceed.Grid.GridControl, ByVal ds As DataSet)

    grid.BeginInit()

    grid.Clear()

    grid.SynchronizeDetailGrids =

    True

    grid.SetDataBinding(ds, ds.Tables(0).TableName)

    grid.FixedHeaderRows.Add(

    New ColumnManagerRow())

    Dim dgrid1 As New DetailGrid()

    dgrid1.SetDataBinding(ds,

    “Total.TotalDate”)

    dgrid1.HeaderRows.Add(

    New ColumnManagerRow())

    dgrid1.Collapsed =

    True

     

    grid.DetailGridTemplates.Add(dgrid1)

    grid.UpdateDetailGrids()

    grid.Columns(EstGrid.Commodity).Title =

    “Commodity”   <—-Where error is thrown

     

    When I look at the grid object in debug mode, I see that the datasource is set to the dataset I give to it.  But I can’t figure out why no columns are being created.  I’ve checked the dataSet and the tables have multiple rows/columns.

    Imported from legacy forums. Posted by jzero (had 996 views)

    Xceed Support
    Member
    Post count: 5658

    The problem here is that you are calling the BeginInit() method and the GridControl is waiting for the EndInit() call to create the columns.

    ‘In the end 

    grid.EndInit()

    grid.UpdateDetailGrids()

    grid.Columns(EstGrid.Commodity).Title = “Commodity”

     

    Imported from legacy forums. Posted by CharlesB (had 1342 views)

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