Cell Type depending on Cell Value

How can I change the celltype depending on a cell value. ie. if cell value of the current cell is a number then show the change the celltype to a numericupdown (same with dates or text or ...) Peter

1 Reply

AD Administrator Syncfusion Team April 4, 2003 07:40 AM UTC

You can handle PrepareViewStyleInfo and dynamically change teh celltype there.
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.ColIndex > 0 && e.RowIndex > 0)
	{
		try
		{
			double d = double.Parse(e.Style.Text);
			e.Style.CellType = "NumericUpDown";
			e.Style.CellValueType = typeof(double);
			return;
		}
		catch
		{
		}

		try
		{
			DateTime dt = DateTime.Parse(e.Style.Text);
			e.Style.CellType = "MonthCalendar";
			e.Style.CellValueType = typeof(DateTime);
			return;
		}
		catch
		{
		}
	}
}

Loader.
Up arrow icon