I have an ultragrid with one of the columns having a valuelist of all employees. I set the column style to DropDownValidate (since I want AutoComplete but do not want the user to add values that aren't in the list). I wanted to capture the CellDataError event and put my own messagebox instead of the generic one, but I noticed that the event fires multiple times for one error, thereby displaying multiple error messageboxes in a row.
Do you know why this would be happening and how to prevent it so that it is only called once?
Thank you for your assistance, ~Kelly
Hi Mike,
I tried Console.Writeline and it still fired 2x. If I utilize the UseDataErrorInfo property, how do I feed that to my error provider, and during which event?
Thank you for your help! ~Kelly
I wonder if the MessageBox is somehow throwing off the timing. Try taking that out - maybe just put in a Debug.Writeline or Console.WriteLine instead and see if the event still fires multiple times. If that solves the issue, the perhaps you need to display the MessageBox using a BeginInvoke rather than directly inside the CellDataError event. I find it odd that the CellDataError event doesn't have a param to cancel the default error message. I assume this is because the error message isn't displayed until the Error event. So maybe that's where you need to display your MessageBox, too.
If you want to show errors without a messagebox, then the only support for that in the grid is the UseDataErrorInfo property, which picks up data errors from the DataTable's IDataErrorInfo implementation.
Is there a way to do it by skipping the CellDataError event altogether and just somehow passing it to my ErrorProvider (which I set through DataTable_OnRowChanging).
Thanks!~Kelly
The Grid Displays Department and the Employee who is the direct for that department. Its datasource is a datatable I filled from our SQL db. The following appears when you add a new row (I use an error provider):
The direct column has a value list with all of the employees. The column has a DropDownValiate style and Suggest AutoCompleteMode:
I chose DropDownValidate since I do not want them to type someone that does not exist. I then wanted to capture the generic error and display a custom one, so I put this in the CellDataError event of the grid:
Private Sub AvtGrid_SystAdmin_CellDataError(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellDataErrorEventArgs) _ Handles AvtGrid_SystAdmin.CellDataError e.RaiseErrorEvent = False MessageBox.Show("You Must Choose a Valid Employee from the List", _ "Invalid Employee", MessageBoxButtons.OK, MessageBoxIcon.Error)End Sub
When the user types an invalid person and commits the record:
The CellDataError event is called multiple times (never the same numer, sometimes 2x, sometimes 5x, etc). This occurs even if I have no code in that event, in which case this is the generic error:
I will attempt to recreate this in a sample project and get back to you with an update, but any help you could give would be much appreciated!~Kelly
Hi Kelly,
I am not aware of any reason why the evert would fire twice, unless there are two errors. Can you duplicate this behavior in a small sample project? What kind of error are you getting? What are you doing in the Error and/or CellDataError events of the grid?