I have a cell that has an ID for an employee. The cell's valuelist is a UltraDropDown control. When the user types into it, if the value does not exist in the drop down I need some code to fire off that creates a new Employee based off of what they typed in. The problem is that I can't figure out how to do that. I am trying to use the CellDataError event to stop the invalid data error from coming up, but in that event I don't have access to the text that the user typed in so I can't create my new employee. Does anyone have any ideas how I can accomplish what I need?
Thanks.
Try using the BeforeExitEdtiMode event of the grid. You can call IsItemInList on the UltraDropDown to determine if the item is on the list.
Mike,
I am looking for the same type of functionality. I have UltraDropDown controls assigned to the ValueList property of some WinGrid cells. In these cells I would like the user the ability to enter a value and if it is not in the UltraDropDown, then I will pop up a form to allow them to enter a new record, and add it to the lookup datatable. You state you can use the IsItemInList method off the UltraDropDown to determine if the text entered is in the UltraDropDown. I do not see this method on the UltraDropDown. I see it on the UltraCombo. What can you use on the UltraDropDown?
Mike
I attempted to use your suggestion.
Here is my code:
Private Sub ug1_BeforeExitEditMode(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeExitEditModeEventArgs) Handles ug1.BeforeExitEditMode If e.CancellingEditOperation = True Then Return End If Dim ivl As IValueList Dim iIndex As Integer If Me.ug1.ActiveCell.Column.Key = "Approval_Status_Id" Then ivl = Me.ug1.ActiveCell.ValueListResolved If Not ivl Is Nothing Then ivl.GetText(Me.ug1.ActiveCell.Text, iIndex) End If End If
You will notice that I am passing ActiveCell.Text as .Text contains the value I typed (valid or invalid). At this event ActiveCell.Value is Null. Using .Text always returns -1. I attempted doing ivl.GetText(CType(me.ug1.ActiveCell.Text, Object, iIndex), but that did not work either.
Your assistance is appreciated.
Thanks
Lonnie
Hi,
That's odd. I'm not sure why UltraDropDown doesn't have the same method.
Anyway, what you can do is cast the UltraDropDown into an IValueList. This will be done for you if you simply get it from the ValueListResolved property of the grid cell.
Then you can use the GetText method and pass in a value. If the item is not on the list, the index returned will be -1.