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.

Reg Validation

Thread ID:

Created:

Updated:

Platform:

Replies:

30401 Jun 17,2005 01:13 AM Jun 17,2005 04:25 AM Windows Forms 1
loading
Tags: GridControl
Anna Srinivasan
Asked On June 17, 2005 01:13 AM

Hi, I am using syncfusion custom control derived from gridControl.How do i validate string, number and currency field validation..? Please send me solution with example. Thanks, Anna

Administrator [Syncfusion]
Replied On June 17, 2005 04:25 AM

You can handle the CurrentCellValidaung event. There use the grid.CurrentCell.ControlText to get teh new value, and set e.Cancel if it is not a proper value. You can also set grid.CurrentCell.ErrorMessage if you want to see a message displayed. Here is a snippet that assume column 5 is an double, and requires any new entry be larger than teh old entry.
private void gridControl1_CurrentCellValidating(object sender, CancelEventArgs e)
{
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	object oldValue = this.gridControl1[cc.RowIndex, cc.ColIndex].CellValue;
	string newValue = cc.Renderer.ControlText;

	//some check on column 5 - assumes column 5 is of CellType == typeof(double)
	if(cc.ColIndex == 5 && oldValue != null && oldValue.ToString().Length > 0)
	{
		double d;
		if(double.TryParse(newValue, System.Globalization.NumberStyles.Any, null, out d))
		{
			if(d < (double) oldValue)
			{
				e.Cancel = true;
				cc.ErrorMessage = string.Format("value must be larger than {0:F3}", oldValue);
			}
		}
	}
}

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.

;