I have a grid in which certain columns/cells have a MaskInput and Format. For example:
column.Format = "dd/MM/yyyy";column.MaskInput = "dd/mm/yyyy";
This all works fine as long as the entered data can be converted to the column DataType (in this case obviously DateTime). But if the user accidently enters __/__/2008 the conversion fails and a popup is shown with following error message:
Unable to update the data value: Value in the editor is not valid.
Is it possible to supress the error dialogbox? I don't want it to show. I would prefer the grid discards the invalid entered info (and reverts to the old value) or enters a default value.
- Infragistics .NET Advantage for Windows Forms 2008 Volume 2
Thanks!
Hi Marc,
There is an CelldataError Event ..use that and withinset
e.RaiseErrorEvent = False
If u want to retain the old value u set this prop
t = False
e.RestoreOriginalValue=true
to stay in edit mode
e.StayInEditMode
Hope this helps you ........
hppy koding ,
Arun
hello arun,
i have used the above coding with a little alteration.
e.RestoreOriginalValue = False
e.StayInEditMode = True
In the above case e.StayInEditMode is Not Working in a proper way, since if we click buttons then the cursor leaves from the cell and switches to button events.
Is there any other way to get rid of the above issue?
Regards
Janani.S
Hi Janani,
I tried this out and I see that if I click on a button, the Button_Click event does fire, but I still see a blinking caret in the cell. So the cell is still in edit mode and that seems like it's working correctly.
Having a cell in edit mode doesn't necessarily prevent the grid from losing focus. If that's what you want, I think you would have to handle the Validating event of the grid, also.
For example, you could do something like this:
Private Sub UltraGrid1_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles UltraGrid1.Validating Dim success As Boolean = Me.UltraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode, False, False) If (Not success) Then e.Cancel = True End If End Sub
Even using Grid_validating event , Button Click events getting executed.
I tried this out and it worked fine for me. The Button_Click does not get fired because the grid maintains the focus. The button therefore never gets focus and the click event does not fire.
Are you using a Button control, or some other kind of button that doesn't need focus, like a toolbar button? If you are using a Toolbar button, then there is no way to stop that event from firing no matter what control you are validating, since a Toolbar button does not require focus.