AD
Administrator
Syncfusion Team
April 19, 2005 11:28 AM UTC
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 08:35 AM UTC
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 09:37 AM UTC
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 21, 2005 03:16 AM UTC
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 07:16 AM UTC
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.