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.
Unfortunately, activation email could not send to your email. Please try again.

Problem with combobox cell of GridDataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

23360 Jan 11,2005 02:32 AM Jan 19,2005 11:32 PM Windows Forms 6
loading
Tags: GridControl
David Bosak
Asked On January 11, 2005 02:32 AM

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,

Administrator [Syncfusion]
Replied On January 11, 2005 04:33 AM

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)
{
	if(e.RangeList.AnyRangeIntersects(GridRangeInfo.Col(2)))
		e.Handled = true; //don''t let the grid handle it
}

David Bosak
Replied On January 13, 2005 02:13 AM

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!

Administrator [Syncfusion]
Replied On January 13, 2005 07:41 AM

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.

David Bosak
Replied On January 13, 2005 06:32 PM

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,

Administrator [Syncfusion]
Replied On January 14, 2005 12:39 AM

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; } }

Administrator [Syncfusion]
Replied On January 19, 2005 11:32 PM

Thanks for your help!

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;