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

ValidateFailed and CurrentCellAcceptedChanges problems

Thread ID:





36598 Nov 3,2005 01:36 PM UTC Nov 4,2005 01:45 PM UTC WinForms 8
Tags: GridControl
Asked On November 3, 2005 01:36 PM UTC

I have some problems with the CurrentCellAcceptedChanges and ValidateFailed events. I need to be able to enter both numbers and expressions into a databoundgrid with a column of double celltypes. The CurrentCellAcceptedChanges raises after the internal error from the grid saying that the entered value is not a valid double (for instance 25.0+30.0) The ValidateFailed event triggers just perfect in time but when I use the currentCell colindex and rowindex I found that it represents the next cell we have moved after pressing TAB or enter or similar. Can I somehow get hold of the last cell that holds my expression? /Tomas

Administrator [Syncfusion]
Replied On November 3, 2005 01:49 PM UTC

ValidateFailed normally has the offending cell as the currentcell. Here is a simple sample showing this. http://www.syncfusion.com/Support/user/uploads/GDBG_CheckBox_de53c4ff.zip Are you handling other events that may try to position the current cell?

Replied On November 3, 2005 02:59 PM UTC

Ah yes, I listen to the CurrentCellKeyDown event to be able to control what should happen when leaving the cell depending on which button that was pressed - this event I presume raises first?. Is there any other events that I can use or how can I solve this? Btw, is there some list of all events and what order they fire available?

Administrator [Syncfusion]
Replied On November 3, 2005 03:52 PM UTC

You could try this. In the CurrentCellValidating event, you can cache the CurrentCell.RowIndex and CurrentCell.ColIndex in some private variables. Then you could use these variables in ValidateFailed to get where the old current cell was. The samples in the \Essential Studio\\Windows\Grid.Windows\Samples\CellTypes folder have an event log class that you can use to see a log of the currentcell events.

Replied On November 4, 2005 08:20 AM UTC

I have managed to get the correct information in the ValidateFailed event, the problem now is how can I store my evaluated expression back to the gridcell so that it won''t display the error: "35+45 is not valid for a Double". Setting e.Handled = true doesn''t seem to be enough. Niether to store the correct value into the StyleInfo.CellValue property. Any thoughts?

Administrator [Syncfusion]
Replied On November 4, 2005 10:49 AM UTC

If your datasource expects a double, then you cannot put a string into the datasource. This means you cannot put a string into style.CellValue because that goes to the DataSource (the GridDataBoundGrid has no where else to put it). If you want to store extra information on a double column (like a formula string), then you will have to add some kind of datastore to manage this. In SaveCellInfo, you take the extra information and put it into your DataStore, and in QueryCellInfo, yougetthe information from the DataStore and put it into the cell. There may be problems trying to get this to work if you are sometimes putting a string into a Cell and sometime putting a double into a cell (and the underlying datasource requires a double). Take a look at this KB. It does something similar, storing additional information for cells. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=104

Replied On November 4, 2005 11:02 AM UTC

Thanks for the information Clay, but this is not really what I intend to do. 1. If the user enters a double value it should be stored as usual. 2. If the user enters an expression, for instance 35+58 or 12*54*(3-5) then I want to evaluate this expression to a double value before storing it to the grid. I don''t need to store the expression itself. 3. If the user enters something else, for instance "hello" then the grid should show this error message saying its not valid. Now, the evaluation part is solved, I always get a double value in the end. My only problem is that I don''t understand how I can store this double value into the grid and say that validation is OK. (ie. I want to take care of the validation myself more or less)

Administrator [Syncfusion]
Replied On November 4, 2005 11:18 AM UTC

You should try handling the CurrentCellvalidating event. There get the proposed string from grid.CurrentCell.Renderer.ControlText. If you get "14 + 15", then set grid.CurrentCell.Renderer.Control.Text = "29", and let the grid continue handling things. If you get "14" or "abc", then do nothing and just let teh grid handle it. (Notice in the above code, one place it is ControlText and the other it is Control.Text.)

Replied On November 4, 2005 01:45 PM UTC

Now it works just fine! Thank you Clay, you are my hero!


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