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.

Cell Type depending on Cell Value

Thread ID:

Created:

Updated:

Platform:

Replies:

3731 Apr 4,2003 01:19 AM Apr 4,2003 02:40 AM Windows Forms 1
loading
Tags: GridControl
Peter
Asked On April 4, 2003 01:19 AM

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

Administrator [Syncfusion]
Replied On April 4, 2003 02:40 AM

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

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.

;