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.

CellValue.CellValueType

Thread ID:

Created:

Updated:

Platform:

Replies:

14521 May 28,2004 02:50 AM Jun 2,2004 05:16 AM Windows Forms 8
loading
Tags: GridControl
Barbara Arz
Asked On May 28, 2004 02:50 AM

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 04: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

Administrator [Syncfusion]
Replied On May 28, 2004 10:45 PM

I am using Version 1.6.1.8 BR Barbara

Administrator [Syncfusion]
Replied On May 28, 2004 11: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?

Administrator [Syncfusion]
Replied On May 31, 2004 11: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)

Administrator [Syncfusion]
Replied On June 1, 2004 02: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

Administrator [Syncfusion]
Replied On June 1, 2004 03: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;
		}
	}
}

Jim Jackson
Replied On June 2, 2004 01: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

Administrator [Syncfusion]
Replied On June 2, 2004 05: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

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.

;