I am coding with .NET and NetAdvantage for Windows Forms 2008. I have an UltraGrid and some buttons on my form. When I use the BeforeExitEditMode event to test for data validation I have to click the form button twice to get it the button event to fire. When I comment out the BeforeExitEditMode the form events work just fine. Is this a monster that I have created or is it an issue with UltraGrid?
It sounds to me like you must be doing something in BeforeExitEditMode like setting e.Cancel to true and thus preventing the grid from losing focus the first time it tries.
What exactly is your code in the BeforeExitEditMode event doing?
Hi Mike,
Thanks for the response. I have the following code in the event:
Private Sub UltraGrid1_BeforeExitEditMode(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeExitEditModeEventArgs) Handles UltraGrid1.BeforeExitEditMode If Me.UltraGrid1.ActiveCell.Column.Key = "TRCODE" Then If IsDBNull(Me.UltraGrid1.ActiveRow.Cells(0).Text) = False _ AndAlso Me.UltraGrid1.ActiveRow.Cells(0).Text > "0" _ AndAlso Me.UltraGrid1.ActiveRow.Cells(0).Text < "9999" Then Err_TRCODE = False Else Err_TRCODE = True End If End IfEnd Sub
But I have taken all that code out of the event, leaving just the Event Sub Statements and it still does the same thing. It seems like something with the focus.
If I change a cell in the grid and then press the "Exit" button and the debug goes through the BeforeExitEditMode event and then focus goes to the form. The "Exit" button is highlighted. If I press the button again, the programs exits.
If I comment out the BeforeExitEditMode Event Sub Statements and do the same test, the exit works normally.
I want to check the data in the cell before moving off of the cell, except when the user presses the exit button. At that point, it doesn't matter what they changed on the grid, it will not get populated to the database. Am I using this event when I should be using another one?
If simply having the event hooked with no code has any effect at all on your application, then something is wrong. That should never happen. I recommend that you create a small sample project demonstrating the issue and Submit an incident to Infragistics Developer Support so they can check it out.