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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback


Thread ID:





14521 May 28,2004 06:50 AM UTC Jun 2,2004 09:16 AM UTC WinForms 8
Tags: GridControl
Barbara Arz
Asked On May 28, 2004 06:50 AM UTC

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

Administrator [Syncfusion]
Replied On May 28, 2004 08:01 AM UTC

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

Administrator [Syncfusion]
Replied On May 29, 2004 02:45 AM UTC

I am using Version BR Barbara

Administrator [Syncfusion]
Replied On May 29, 2004 03:50 AM UTC

I tried the above sample using, and it seemed to allow me to delete the contents of a cell whose cellvalue type is double. (Since it was done with 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 Does the sample work for you? What are you doing differently?

Administrator [Syncfusion]
Replied On June 1, 2004 03:05 AM UTC

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)

Administrator [Syncfusion]
Replied On June 1, 2004 06:43 AM UTC

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

Administrator [Syncfusion]
Replied On June 1, 2004 07:55 AM UTC

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)
				cc.Renderer.Control.Text = "";
				this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].Text = "";
			e.Cancel = true;

Jim Jackson
Replied On June 2, 2004 05:48 AM UTC

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

Administrator [Syncfusion]
Replied On June 2, 2004 09:16 AM UTC

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 = ""
            Me.gridDataBoundGrid1(cc.RowIndex, cc.ColIndex).Text = ""
         End If
         e.Cancel = True
      End If
   End If
End Sub ''gridDataBoundGrid1_CurrentCellValidateString


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

Live Chat Icon For mobile
Live Chat Icon