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

How to catch SelectedIndexChanged event of Combobox Column in GDBG?

I want to catch the SelectedIndexChanged event of ComboBox Column in GDBG as a normal Combobox control in C#. But GDBG doesn''t support it. How can I do that ? Thanks

5 Replies

AD Administrator Syncfusion Team April 19, 2005 06:28 AM

Generally you would use the CurrentCellChanged event to catch when the selected index of a combobox changed. But if you want to get at the SelectedIndexCahnged event you can. Note that there is only one combobox and it is shared among all cells that have a ComboBox CellType so you will need to take this into consideration as you catch this event. You catch add code like this in Form.Load to subscribe to the event for all cells. GridComboBoxCellRenderer cc = this.grid.CellRenderers["ComboBox"] as GridComboBoxCellRenderer; cc.ListBoxPart.SelectedIndexChanged += new EventHandler(combo_SelectIndexChanged);


AD Administrator Syncfusion Team April 20, 2005 03:35 AM

Yes, you''re right. I should use the CurrentCellChanged event instead of using SelectedIndexChanged event. Now, I want to know the valuemember in any cells which have a ComboBox CellType instead of displaymember. I try to use : GridCurrentCell cc = dgr.CurrentCell; GridComboBoxCellRenderer cb = cc.Renderer.Control as GridComboBoxCellRenderer; and use cb.ListBoxPart.SelectedValue.ToString(); But It makes an error. How to resolve this problem,please? I want to get it in any cells which have a ComboBox CellType, not just in CurrentCell. Thanks >Generally you would use the CurrentCellChanged event to catch when the selected index of a combobox changed. > >But if you want to get at the SelectedIndexCahnged event you can. Note that there is only one combobox and it is shared among all cells that have a ComboBox CellType so you will need to take this into consideration as you catch this event. > >You catch add code like this in Form.Load to subscribe to the event for all cells. > >GridComboBoxCellRenderer cc = this.grid.CellRenderers["ComboBox"] as GridComboBoxCellRenderer; >cc.ListBoxPart.SelectedIndexChanged += new EventHandler(combo_SelectIndexChanged); > > >


AD Administrator Syncfusion Team April 20, 2005 04:37 AM

The ListBoxPart is only around when the combobox is dropped. It has been destoryed by the time CurrentCellChanged is hit. To get the displaymember, try cc.Renderer.ControlText To get the ValueMember, try cc.Renderer.ControlValue


AD Administrator Syncfusion Team April 20, 2005 10:16 PM

But I want to get valuemember not only in CurrentCell,but also in the other cells which are ComboBox CellType .


AD Administrator Syncfusion Team April 21, 2005 02:16 AM

If the cell is not current, then grid[rowIndex, colIndex].Cellvalue should return the ValueMember and grid[rowIndex, colIndex].FormattedText should return the DisplayMember. When a cell is actively being edited, you need to go through the Renderer to get these values.

Loader.
Live Chat Icon For mobile
Up arrow icon