Hallo,
I'd like to delete items from an UltraCombos DropDownList by pressing the delete key on the keyboard. Since the items change their color when the mouse is moved over the dropped down list, I thought it would be easy to determine the index of the item where the mouse is over when pressing delete. Unfortunatly an item is not a SelectedItem until it is clicked on. Then it's too late to delete it the way I want to.
How to suppress the item then is easy (ValueList, database), but finding out which one it is in this context is the problem.
I hope you can help me to resolve it.
Thanks,
Michael
Hello Michael,
I prepared and attached a sample for you to this post, regarding the desired behavior. Please review it and feel free to let me know if I misunderstood you or if you have any other questions.
Hello Boris,
thank you very much for your answer and the code. I understand it and I'm sure it works but unfourtunatly I forgot to mention in my first post that I'm trying to solve this problem in VB.net.
So it must be my translation below (the events only) why it doesn't work out. My comments indicate where I guess the mistakes.
Dim rowIndex As IntegerDim isMouseOverRow As Boolean = FalsePrivate Sub cboFind_MouseEnterElement(ByVal sender As Object, ByVal e As Infragistics.Win.UIElementEventArgs) Handles cboFind.MouseEnterElement Try Dim el As Infragistics.Win.UltraWinGrid.RowUIElement = GetUI(e.Element) ' The translation of your "if (el is RowUIElement)" never becomes true, rowIndex never changes ' But of course the reason may be found as well in the translation of "GetUI(UIElement el)" If TypeOf el Is Infragistics.Win.UltraWinGrid.RowUIElement Then rowIndex = el.Row.Index isMouseOverRow = True lblRowIndex.Text = rowIndex ' A "Debug-Label" never changes its .Text End If Catch ex As Exception m_objMyParent.m_objErrorHandler.HandleError(ex, INODBG.clsDBG.OutputTypes.MessageBox) End TryEnd SubPrivate Sub cboFind_MouseLeaveElement(ByVal sender As Object, ByVal e As Infragistics.Win.UIElementEventArgs) Handles cboFind.MouseLeaveElement Try ' Here you wrote "if (e.Element.GetType() == typeof(RowUIElement))" and I'm sure that my code is different from yours If TypeOf e.Element Is Infragistics.Win.UltraWinGrid.RowUIElement Then isMouseOverRow = False End If Catch ex As Exception m_objMyParent.m_objErrorHandler.HandleError(ex, INODBG.clsDBG.OutputTypes.MessageBox) End TryEnd SubPrivate Function GetUI(ByRef el As Infragistics.Win.UIElement) As Infragistics.Win.UltraWinGrid.RowUIElement Try If el Is Nothing Then Return Nothing If TypeOf el Is Infragistics.Win.UltraWinGrid.RowUIElement Then Return el Else Return GetUI(el.Parent) End If Catch ex As Exception m_objMyParent.m_objErrorHandler.HandleError(ex, INODBG.clsDBG.OutputTypes.MessageBox) End TryEnd Function
Thanks a lot in advance,
Hi Boris,
thank you very much for asking if everything works well here. Indeed, there is still one thing left I wanted to ask you for help. After implementing your code the only line which is deleted is the last one in the Combo. Not the one where the mouse is over. So the detection of the correct line fails.
Do you have any idea why?
Best regards,
Hi Michael,
Please try the attached sample and let me know if that is what you are looking for.
Hello,
I am just checking about the progress of this thread. Let me know If you need my further assistance on this.
I completely forgot to thank you very much again for all your exellent assistance. Of course, it works!
I am very happy to hear this. If you need a hint or a sample project or code, please feel free to contact me, I will be glad to assist you again.