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

Number Mask

Hi, How can i set mask for a range of cell or a cell in GDBG? I want user to enter only decimal values. Something like "#,###,###.##" Thanks

2 Replies

VI Vivek May 25, 2004 05:58 PM

I figured it out that how to set mask. But when I am trying to enter decimal value in a cell I am getting following error “Input string was not in correct format” Just to remind that I am setting mask in GridDataBundGrid control in a multirowrecord view. Please help me. Because this my formulas are also not working. Thanks


AD Administrator Syncfusion Team May 26, 2004 01:57 AM

There are several ways you can approach this problem. The way I would try to do it is to make sure teh column type is set to double an dthe Format is set teh way you want it. this.gridDataBoundGrid1.Binder.InternalColumns[1].StyleInfo.CellValueType = typeof(double); this.gridDataBoundGrid1.Binder.InternalColumns[1].StyleInfo.Format = "#,###.00"; This should allow you to enter and see teh values. And if your users types an invalid valid, you will get a message. If you want to make it so you user cannot type a invalid value, I would handle the CurrentCellValidateString event and vaildate the string with each key stroke to see if make sure the entry is valid.
private void gridDataBoundGrid1_CurrentCellValidateString(object sender, GridCurrentCellValidateStringEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.ColIndex == 2)
	{
		double d;
		if(!double.TryParse(e.Text, System.Globalization.NumberStyles.Any, null, out d))
		{
			e.Cancel = true;
		}
	}
} 

Loader.
Live Chat Icon For mobile
Up arrow icon