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

Problem with combobox cell of GridDataBoundGrid

I am working with Combobox cell of GridDataBoundGrid But I don''t want users to delete the selected value of Combobox cell. Please let me know how to do that? Thanks,

6 Replies

AD Administrator Syncfusion Team January 11, 2005 09:33 AM UTC

You can handle the grid.Model.ClearingCells event and set e.Handled = true if e.RangeList holds a cell that you do not want to clear. Here is a little snippet that does not clear anything that includes column 2.
private void Model_ClearingCells(object sender, GridClearingCellsEventArgs e)
		e.Handled = true; //don''t let the grid handle it

DB David Bosak January 13, 2005 07:13 AM UTC

when I delete the value of combobox cell, the application does not go through your code (I meant the application doesn''t raise that event). Please help!

AD Administrator Syncfusion Team January 13, 2005 12:41 PM UTC

This event should be hit when your user selects a range of cells (by mousing down and dragging several cells) and presses the delete key. If this is what is not working for you, can you tell us how to see this problem in one of our samples, or upload a sample showing the problem. Also indicate the version of our libraries that you are using. Now if your user is editing the combobox entry with the keyboard and blanks out the cell in this manner, the above event will not be hit. To catch this behavior, you can handle the CurrentCellValidating event, and if grid.CurrentCell.Renderer.ControlText.Length = 0, then set e.Cancel = true. This should prevent your user from leaving an empty cell that they have edited.

DB David Bosak January 13, 2005 11:32 PM UTC

In your example ComboBox_CellValue.zip. - running example - double click on Combobox cell (the cell Text is selected all) - press ''Delete'' key (the Text will be deteted) How can I prevent the deletion above? Thanks,

AD Administrator Syncfusion Team January 14, 2005 05:39 AM UTC

I am not sure exactly what sample you are referring to: "In your example ComboBox_CellValue.zip". Did you get it from a particular forum link or Direct Trac incident? I think you can handle this problem by : 1) in Form.Load, subscribe to the KeyDown event of the embedded textbox of the cellrenderer. GridComboBoxCellRenderer cr = this.gridDataBoundGrid1.CellRenderers["ComboBox"] as GridComboBoxCellRenderer; if(cr != null) { cr.EditPart.KeyDown += new KeyEventHandler(EditPart_KeyDown); } 2) Use a handler similar to : private void EditPart_KeyDown(object sender, KeyEventArgs e) { TextBoxBase tb = sender as TextBoxBase; if(tb != null && e.KeyCode == Keys.Delete && tb.SelectionLength == tb.TextLength) { e.Handled = true; } }

AD Administrator Syncfusion Team January 20, 2005 04:32 AM UTC

Thanks for your help!

Live Chat Icon For mobile
Up arrow icon