We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

assigning new datasource to combobox in grid at runtime.

I am using SyncFusion''s essential grid and i am facing the following problem:- I have a grid with on column consisting of Combo-boxes,I assign a datasource to the grid while loading it.Now when I try to change the values of those comboboxes(in the grid),I am not able to change the values or even make the combo box readonly.I tried using the same technique given in syncfusion''s documentation but it is not working.Following is the code that I wrote. Dim oClaimStatusDT As DataTable Dim oColumn1 As DataColumn Dim row1 As DataRow Dim row2 As DataRow Dim row3 As DataRow oSomeDT= New DataTable oColumn1 = New DataColumn("SomeHeading") oSomeDT row1 = oClaimStatusDT.NewRow row1(0) = "SomeValue" oSomeDT.Rows.Add(row1) row2 = oClaimStatusDT.NewRow row2(0) = "SomeOtherValue" oSomeDT.Rows.Add(row2) row3 = oClaimStatusDT.NewRow row3(0) = "StillAnotherValue" oSomeDT.Rows.Add(row3) Dim oSomeDataView As New DataView(oSomeDT) SomeGridWithCombos((iIndex + 1), iColumnIndex).DataSource = oSomeDataView SomeGridWithCombos((iIndex + 1), iColumnIndex).ValueMember = "SomeHeading" SomeGridWithCombos((iIndex + 1), iColumnIndex).DisplayMember = "SomeHeading"

3 Replies

AD Administrator Syncfusion Team August 10, 2005 08:36 AM

In a GridDataBoundGrid, you cannot set properties(other than the CellValue) using an indexer on the there are several KB''s in the GridDataBoundGrid section of the grid KS''s that discuss this. Instaed, to set such properties, you need to use eitehr PrepareViewStyleInfo or Model.QueryCellInfo to dynamically set such properties. This KB shows one such way. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=102


SN Srirang Netake August 11, 2005 06:26 AM

Thanks Clay , I am trying to use the QueryCellInfo event for assigning a different datasource to the combobox cell as given in the solution provided in the link u gave me but the problem is this event doesen''t get fired explicitly.I''ll explain the scenario: On form load the my grid is filled with normal data,and after this ,in form load itself,there is another function which loads data specific to the parent form(my from with grid has 3 different parent forms) I want to assign a different datasource to tht combobox in this second function so I tried raising the querycellinfo event from this function but it didn''t work. NOTE:-the earlier code had an incorrect table name so I am giving the code again. Dim oClaimStatusDT As DataTable Dim oColumn1 As DataColumn Dim row1 As DataRow Dim row2 As DataRow Dim row3 As DataRow oSomeDT= New DataTable oColumn1 = New DataColumn("SomeHeading") oSomeDT row1 = oSomeDT.NewRow row1(0) = "SomeValue" oSomeDT.Rows.Add(row1) row2 = oSomeDT.NewRow row2(0) = "SomeOtherValue" oSomeDT.Rows.Add(row2) row3 = oSomeDT.NewRow row3(0) = "StillAnotherValue" oSomeDT.Rows.Add(row3) Dim oSomeDataView As New DataView(oSomeDT) SomeGridWithCombos((iIndex + 1), iColumnIndex).DataSource = oSomeDataView SomeGridWithCombos((iIndex + 1), iColumnIndex).ValueMember = "SomeHeading" SomeGridWithCombos((iIndex + 1), iColumnIndex).DisplayMember = "SomeHeading" >In a GridDataBoundGrid, you cannot set properties(other than the CellValue) using an indexer on the there are several KB''s in the GridDataBoundGrid section of the grid KS''s that discuss this. > >Instaed, to set such properties, you need to use eitehr PrepareViewStyleInfo or Model.QueryCellInfo to dynamically set such properties. This KB shows one such way. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=102


AD Administrator Syncfusion Team August 11, 2005 07:38 AM

To force QueryCellInfo to be raised, you can call grid.Refresh or grid.RefreshRange. You also need to subscribe to the event using AddHandler. One other comment on this. >>SomeGridWithCombos((iIndex + 1), iColumnIndex).XXXXX = YYYYY In a GridDataBoundGrid, you do not use code like this unless XXXXX is CellValue or Text. The GridDataBoundGrid cannot store any other properties like this (unless you handle Model.SaveCellInfo and save these values omewhere yourself, and then use these saved values in Model.QueryCellInfo to provdie these saved values when the grid needs them.

Loader.
Live Chat Icon For mobile
Up arrow icon