ColorEdit in cell does not work if the cellvalue is invalid

Hi, I have a GridDataBoundGrid and a couple of columns of which are of type ColorEdit. If I edit the cell value directly (not by color pallette dropdown) and change the string to something that cannot be converted to a valid color, the cell does accept the value. But then, clicking the dropdown button for the color palette does not work. The same thing happens if I change the column value in the datasource table manually and try to click on the dropdown for the corresponding cell. Is there a workaround for this please? Babu.

2 Replies

AD Administrator Syncfusion Team February 22, 2004 08:21 AM UTC

Try handling CurrentCellValidateString, and set e.Cancel = true if the color is not valid.
private void gridDataBoundGrid1_CurrentCellValidateString(object sender, GridCurrentCellValidateStringEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].CellType == "ColorEdit")
	{
		string s = e.Text;
		try
		{
			Color c = (Color)TypeDescriptor.GetConverter(typeof(Color)).ConvertFromString(s); 
		}
		catch
		{
			e.Cancel = true;
		}
	}
}


BM Babu Mannaravalappil February 22, 2004 11:47 AM UTC

Thanks Clay. It is really exhilerating to find that here is a forum where all my questions get attended to so very fast and answered with working solutions. Thanks again and keep it up. Babu.

Loader.
Up arrow icon