Hi,
Recently I'm using UltraGrid in my application.And here is the request, in the first column of the grid I have to use comboEditor column, with the columnStyle to DropDownList.
I customized the UltraComboEditor component, and implement the OnKeyDown event which when I press the "del" button, the value selected will be deleted and the comboEditor will show empty value(not really delete the value, only set with this.SelectedIndex=-1).
Meanwhile, I customized the UltraGrid component, and also implement the OnKeyDown event which should deal with the "del" button when press the "del" button on keyboard it will delete the comboEditor value, which just the effect shown above with the customized comboEditor.
But when I got focued on the comboEditor in the grid, and press the "del" button, it won't delete the value that selected in the comboEditor, which is what I want to implement.
Could you please help me with that? Thanks for your concern.
And I'll attach the sample code that I implement before.
Hi Richard,
Thank you for posting in our forums.
When you press the delete key and the grid is the active control on the form, it handles itself the key. What happens is that the grid executes an action based on its key action mappings collection (for the delete key, when you have a selected row it deletes it). What you could do in order to change this is to handle the delete key in the grid yourself. First set the Handled property in the OnKeyDown method to true if the key is delete and get the active cell or active row and set the value for the cell you want to delete to String.Empty.
I have modified your sample in order to demonstrate this approach.
Please let me know if you have any additional questions.
Hi, Dimitar
Thanks for your help. And I've using your modified code, the value of the ComboEditor could be delete.
But when the value was deleted and I click another cell, it will give an error message :
"Unable to update the data value: Value in the editor is not valid".
When you run the modified code, you could:
1) select a value from the comboEditor in the grid
2) delete the value and click another cell
I've read the topic in this forums, but it seems still unsolved.
http://es.infragistics.com/community/forums/t/79228.aspx
The column style must be DropDownList. How could I solve that? Could you please help me with that?
Thanks for your concern.
Thanks for your help. That's exactly what I need.
Thank you for the reply.
You can resolve this by handling the CellDataError event. In this event you can specify if you want the error to be raised and if you want the cell to stay in edit mode:
void ultraGrid1_CellDataError(object sender, CellDataErrorEventArgs e)
{
var activeCell = ultraGrid1.ActiveCell;
if (activeCell != null && activeCell.Column.Key == "Column1"
&& String.IsNullOrEmpty(activeCell.Text))
e.RaiseErrorEvent = false;
e.StayInEditMode = false;
}
I have modified the sample in order to demonstrate this approach.