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

CellValue.CellValueType

Hi, I want to enter numerical values in a grid, but do this I had to face some problems. Whats the best way to do this? If i set CellValue.CellValueType = Double or Decimal and enter then a not numerical value i get the following exception: System.FormatException: Input string was not in a correct format. at System.Number.ParseDecimal(String s, NumberStyles style, NumberFormatInfo info) at System.Decimal.Parse(String s, NumberStyles style, IFormatProvider provider) at Syncfusion.Windows.Forms.Grid.GridCellValueConvert.Parse(String s, Type resultType, IFormatProvider provider, String format) at Syncfusion.Windows.Forms.Grid.GridCellModelBase.ApplyFormattedText(GridStyleInfo style, String text, Int32 textInfo) at Syncfusion.Windows.Forms.Grid.GridStyleInfo.ApplyFormattedText(String text) at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.OnValidate() If I set ValidateValue.NumberRequired=true, I can only enter numierical values, but I can not set the cell value to empty (null) BR Barbra Arz

8 Replies

AD Administrator Syncfusion Team May 28, 2004 03:01 AM

What version are you using? In the 2.0 code base, you can leave a double cell empty. Attached is a sample that seems to work OK for me. Is there something I am missing? WindowsApplication9_7543.zip


AD Administrator Syncfusion Team May 28, 2004 09:45 PM

I am using Version 1.6.1.8 BR Barbara


AD Administrator Syncfusion Team May 28, 2004 10:50 PM

I tried the above sample using 1.6.1.8, and it seemed to allow me to delete the contents of a cell whose cellvalue type is double. (Since it was done with 2.0.5.1 originally, you will get a couple of syntax errors when you try to compile it, but I just deleted the 2 lines and that made things work OK for me in 1.6.1.8.) Does the sample work for you? What are you doing differently?


AD Administrator Syncfusion Team May 31, 2004 10:05 PM

OK, I made the test. It works, but when i enter non-numerical values I get expections. After this I get an message box, which tells me, that I have entered a value which is no double. But I have solve my problem in an other way now. Thanks for help. Barbara (But if you know, what to do, avoid getting this exception: please let me know)


AD Administrator Syncfusion Team June 1, 2004 01:43 AM

Re deleting value from "double" type cell - I tried sample you attached, Clay and found that by using the Delete key and leaving "nothing" in the cell it works fine - but by using the space key to blank it out, you get the invalid type message on leaving. Is there a way round this as experience tells me that this is the way most users will delete the values ??? Thanks Jim


AD Administrator Syncfusion Team June 1, 2004 02:55 AM

Pressing the delete key is different than typing a space. If you want to ''delete'' an entry when your user types a space, then you will have to handle some event. For example, you could try CurrentCellValidateString and do something there.
private void gridDataBoundGrid1_CurrentCellValidateString(object sender, GridCurrentCellValidateStringEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.ColIndex == 2)
	{
		if(e.Text.IndexOf('' '') > -1)
		{
			if(cc.IsEditing)
				cc.Renderer.Control.Text = "";
			else
				this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].Text = "";
			e.Cancel = true;
		}
	}
}


JJ Jim Jackson June 2, 2004 12:48 AM

Hi Clay, I realise the difference between the keys pressed but a normal user doesn''t - they just want to see the required empty cell. Will that code handle a normal grid as well as a databound grid ? I understand the code but you couldn''t stick the VB version in could you ? Thanks Jim


AD Administrator Syncfusion Team June 2, 2004 04:16 AM

I think the same code should work in a GridControl.
Private Sub gridDataBoundGrid1_CurrentCellValidateString(sender As Object, e As GridCurrentCellValidateStringEventArgs)
   Dim cc As GridCurrentCell = Me.gridDataBoundGrid1.CurrentCell
   If cc.ColIndex = 2 Then
      If e.Text.IndexOf(" ") > - 1 Then
         If cc.IsEditing Then
            cc.Renderer.Control.Text = ""
         Else
            Me.gridDataBoundGrid1(cc.RowIndex, cc.ColIndex).Text = ""
         End If
         e.Cancel = True
      End If
   End If
End Sub ''gridDataBoundGrid1_CurrentCellValidateString

Loader.
Live Chat Icon For mobile
Up arrow icon