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
close icon

Dynamic Drop Down list in GDBG

Before the upgrade to the Syncfusion 3.3 we had following code working. The GDBG cell ( lets called CELL1 ) was setup as a ComboBox. Then the Array List values were assigned to this cell data source. That was done at the grid creation time. While running the program following was happening. Based on the value in the other cell ( lets call it CELL2 )of the same grid the contants of the Array List was modified. So when the CELL1 drop down list was displayed it contants was based on the value of the CELL2 of the same row. This all worked. I could set the value of the CELL2 in the row and drop down for the CELL1 was displaying proper values. This was lost with the upgrade. What is happening right now is following. In the row1 CELL1 drop down will have it value setup correctly. If the CELL1 is drop down in the row 2 it displays same values like in the row 1 even if the Data Source was changed in the mean time. How can I force the change of the drop down list for the cell during the run time? I hope this is clear explanation of the problem.

9 Replies

AD Administrator Syncfusion Team September 28, 2005 12:26 PM UTC

Hi, attached find a sample that dynamically switches the datasource for a combobox on the current row when you click a button in that row. ChangeComboBoxDataSourceAtRuntime.zip Stefan >Before the upgrade to the Syncfusion 3.3 we had following code working. >The GDBG cell ( lets called CELL1 ) was setup as a ComboBox. Then the Array List values were assigned to this cell data source. >That was done at the grid creation time. >While running the program following was happening. >Based on the value in the other cell ( lets call it CELL2 )of the same grid the contants of the Array List was modified. So when the CELL1 drop down list was displayed it contants was based on the value of the CELL2 of the same row. This all worked. I could set the value of the CELL2 in the row and drop down for the CELL1 was displaying proper values. >This was lost with the upgrade. >What is happening right now is following. >In the row1 CELL1 drop down will have it value setup correctly. If the CELL1 is drop down in the row 2 it displays same values like in the row 1 even if the Data Source was changed in the mean time. >How can I force the change of the drop down list for the cell during the run time? > >I hope this is clear explanation of the problem.


KS kstoj September 29, 2005 12:15 AM UTC

I''m implementing my code exactly the same and it does not work. There are some excpetions: 1. My grid is GridDataBoundGrid, which is different than the example 2. Looks like the dynamic Drop Down list does not change only in specific circumstances. Here are the circumstances: 1. Value in the CELL1 decides what the Drop Down list values in the CELL2 are going to be. 2. When the rows in the grid are changed by clicking on the CELL1 and then CELL2 drop down list is expended the drop down list contains the correct values. 3. When the rows grid is navigated by clicking on the CELL2 then the drop down list contains the values from the previous CELL2 disregarding the change of the underlying DataSource for the CELL2 based on the value of the CELL1 in the given row. So the question would be is the CELL2 is grid''s current cell ( int GDBG ) can I still change the cell''s DataSource ( dynamically ) and at what point?


AD Administrator Syncfusion Team September 29, 2005 12:22 AM UTC

Hi, is it possible for you to post a small sample project? That way I can take your project and debug into it. Thanks, Stefan >I''m implementing my code exactly the same and it does not work. >There are some excpetions: >1. My grid is GridDataBoundGrid, which is different than the example >2. Looks like the dynamic Drop Down list does not change only in specific circumstances. > >Here are the circumstances: >1. Value in the CELL1 decides what the Drop Down list values in the CELL2 are going to be. >2. When the rows in the grid are changed by clicking on the CELL1 and then CELL2 drop down list is expended the drop down list contains the correct values. >3. When the rows grid is navigated by clicking on the CELL2 then the drop down list contains the values from the previous CELL2 disregarding the change of the underlying DataSource for the CELL2 based on the value of the CELL1 in the given row. > >So the question would be is the CELL2 is grid''s current cell ( int GDBG ) can I still change the cell''s DataSource ( dynamically ) and at what point? > >


KS kstoj September 29, 2005 04:35 PM UTC

Attached example ilustrates exact problem we are seening in our product. Here are the steps to reproduce the issues: 1. Run the attached application. 2. Click on any "Selector" cell. 3. Click on the the Drop Down list for the "Data1" or "Data2" cell in the SAME row. You will see that the data in the drop down list corresponds to the "Selector" column data. 4. Now do following. 5. Click on the "Data1" drop down list for the first row. 6. The data should be OK. 7. Now click on the Drop Down list for the "Data1" cell in the second row ( DO NOT CLICK on the "Selector" column ) the data in the drop down list is from the "Data1" cell for the first row. THIS is our problem. DropDownLists_7460.zip


KS kstoj September 30, 2005 05:14 PM UTC

Any news on this? I think we can get where the drop down list are refreshed propery. If I use CurrentCellShowingDropDown event instead of the RowEnter event to setup the value of the DropDown lists. However this creates another problem: the AutoComplete feature on these cells don''t work any more. I can''t type data from keyboard the cells only respond to the mouse. ?????


AD Administrator Syncfusion Team October 1, 2005 04:05 AM UTC

Try using CurrentCellShowingDropDown to set the lists instead of RowEnter. http://www.syncfusion.com/Support/user/uploads/DropDownLists_49d5e3d3.zip


AD Administrator Syncfusion Team October 1, 2005 02:58 PM UTC

Hi, It actually works better to do it in CurrentCellActivating. See the following changes: private void gridDataBoundGrid1_CurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e) { System.Diagnostics.Trace.WriteLine("gridDataBoundGrid1_CurrentCellActivating"); GridControlBase grid = (GridControlBase) sender; UpdateSelector(e.RowIndex); } // Just in case Activating current cell failed - reset it back to old setting. private void gridDataBoundGrid1_CurrentCellMoveFailed(object sender, GridCurrentCellMoveFailedEventArgs e) { System.Diagnostics.Trace.WriteLine("gridDataBoundGrid1_CurrentCellActivating"); GridControlBase grid = (GridControlBase) sender; UpdateSelector(grid.CurrentCell.RowIndex); } void UpdateSelector(int rowIndex) { int m_CurrentSelectedRowIndex = rowIndex; if( this.gridDataBoundGrid1.DataSource != null ) if( (this.gridDataBoundGrid1.DataSource as ArrayList).Count > 0 ) this.SetupDataDropDownValues(((Data)((this.gridDataBoundGrid1.DataSource as ArrayList)[m_CurrentSelectedRowIndex-1])).Selector ); } int lastSelector = -1; private void SetupDataDropDownValues( int selector ) { if (selector == lastSelector) return; lastSelector = selector; this.data1Array = new ArrayList(); this.data2Array = new ArrayList(); foreach( Syncfusion.Windows.Forms.Grid.GridBoundColumn gridColumn in gridDataBoundGrid1.GridBoundColumns ) { if( (gridColumn.MappingName == "Data1") || (gridColumn.MappingName == "Data2") ) gridColumn.StyleInfo.DropDownStyle = Syncfusion.Windows.Forms.Grid.GridDropDownStyle.AutoComplete; } for( int i = 0; i < 5; i++ ) { this.data1Array.Add( String.Format( "{0}{1}", selector.ToString(), ((char)(''A''+ i)).ToString()) ); this.data2Array.Add( String.Format( "{0}{1}", ((char)(''A''+ i)).ToString(), selector.ToString()) ); } this.gridBoundColumn2.StyleInfo.DataSource = this.data1Array; this.gridBoundColumn3.StyleInfo.DataSource = this.data2Array; } Stefan


SC Scott August 2, 2016 03:31 PM UTC

This helped to change the datasource for the row and col of the given combobox  as found in the GridDataBoundGrid (GDBG). 
However, the data bound field that we have is an index, and would like the field to show the common name for the value that was selected from the combobox, into the non-data bound cell. (ie fieldmapping is not set.)

1.  If I do not assign a field to the gridboundcolumn mappingname, but want to show a value in that row and column, how would I do this?  do I need to tag the cell as to what was selected and....

I assume that on the CurrentCellDeactivating event I can check for a change of value and the update the corresponding datasource field manually.

<code>

Private Sub GridDataBoundGrid1_CurrentCellActivating(sender As Object, e As Syncfusion.Windows.Forms.Grid.GridCurrentCellActivatingEventArgs) Handles GridDataBoundGrid1.CurrentCellActivating

Dim CurrentCell As Syncfusion.Windows.Forms.Grid.GridCurrentCell = TryCast(sender, Syncfusion.Windows.Forms.Grid.GridDataBoundGrid).CurrentCell

Dim grid = TryCast(sender, Syncfusion.Windows.Forms.Grid.GridDataBoundGrid)

If e.ColIndex < 0 Then Return

If grid.GridBoundColumns(e.ColIndex - 1).HeaderText = gbcBOR_ID.HeaderText Then

' gbcBOR_ID.StyleInfo.CellType = "ComboBox"

Dim table = New DataTable("HaHa")

table.Columns.Add(New DataColumn("col1"))

table.Columns.Add(New DataColumn("col2"))

Dim row = table.NewRow

row("col1") = String.Format("Fred_{0}", e.RowIndex)

row("col2") = String.Format("Winkel_{0}", e.RowIndex)

table.Rows.Add(row)

Dim row1 = table.NewRow

row1("col1") = String.Format("GooGoo_{0}", e.RowIndex)

row1("col2") = String.Format("Minkel_{0}", e.RowIndex)

table.Rows.Add(row1)

grid.GridBoundColumns(e.ColIndex - 1).StyleInfo.DisplayMember = "col1"

grid.GridBoundColumns(e.ColIndex - 1).StyleInfo.ValueMember = "col2"

grid.GridBoundColumns(e.ColIndex - 1).StyleInfo.DataSource = table

If IsNothing(grid.GridBoundColumns(e.ColIndex - 1).StyleInfo.Tag) Then

grid.GridBoundColumns(e.ColIndex - 1).StyleInfo.Tag = -1   ' unknown selection

Else

'grid.GridBoundColumns(e.ColIndex - 1).StyleInfo.SetValue =

End If

End If

' UpdateComboBoxSelector(e.RowIndex)

End Sub

</code>



AR Amal Raj U Syncfusion Team August 3, 2016 01:55 PM UTC

Hi Scott, 
 
Thanks for using Syncfusion products. 
 
In order to get the index of columns which are not included in GridBoundColumns collection, InternalColumns collection can be used. We have created a simple sample based on the provided information to dynamically change cell type and data source of next columns in CurrentCellActivating event. We have changed dynamically the cell type and data source of next column. Please refer to the below sample. 
 
Sample Link 
 
Regards, 
Amal Raj U. 


Loader.
Live Chat Icon For mobile
Up arrow icon