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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Reg Validation

Thread ID:





30401 Jun 17,2005 05:13 AM UTC Jun 17,2005 08:25 AM UTC WinForms 1
Tags: GridControl
Anna Srinivasan
Asked On June 17, 2005 05:13 AM UTC

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 08:25 AM UTC

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);


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon