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
close icon

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.
Live Chat Icon For mobile
Up arrow icon