Hi,
I have a UltraCombo control. Its AutoCompleteMode is set to None. When I click on the editor of the control, I want to display the dropdown. I tried the Click event but this event fires also when you click on the dropdown button. I am looking for an event that works specifically for the editor part of the control only. Any other event I can use to accomplish this?
Thanks,
Jason
Hi Jason,
It sounds like you want to set DropDownStyle to DropDownList. Then the control will always drop down when it is clicked and the user will only be able to choose a value from the list - they won't be able to type into the combo.
If I am wrong, and that's not what you want, then I need a little clarification. You can probably use the MouseDown or MouseUp event and use the UIElements to determine which part of the control was clicked. But it makes a difference whether the control is already in edit mode or not, because when it's in edit mode, it will be displaying a TextBox control over itself. So you might need to hook the Click event of the TextBox instead of the combo - it depends on the behavior you want.
Hi Mike,
Thanks for replying my question.
Let me clarify a little bit. First I need to be able to type in the combo. Second, when I click on the editor part of the combo I want the drop down to display. But when I click on the dropdown button, it should work as it is (Click to show dropdown list and click again to hide dropdown list). When I use UltraCombo's MouseDown/MouseUp/Click event, it applies to all area of the control (versus just the Editor part of the control). I think the UIElements you mention might be the one I am looking for. Could you show me some sample code?
The code here http://help.infragistics.com/Help/NetAdvantage/WinForms/2012.1/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v12.1~Infragistics.Win.UltraWinGrid.UltraCombo~UIElement.html
seems to serve my purpose. Do I still need to hook the Click event of the TextBox?
There are two different cases you may need to deal with.
1) The control does not have focus and the user clicks on the text portion (not the dropdown button).
2) The control has focus (and is therefore showing a TextBox control over itself) and the user clicks onto the edit portion (not the dropdown button).
So my question is... do you want the same behavior in both cases?
And in the latter case, what happens if the dropdown is already dropped down? Do you want to close it? Or do nothing?
Yes I want to have the same behavior for both cases. If the dropdown is already dropped down and users click on the text portion, the dropdown should stay dropped down.
jason
Try this:
private void ultraCombo1_MouseDown(object sender, MouseEventArgs e) { UltraCombo combo = (UltraCombo)sender; UIElement element = combo.UIElement.LastElementEntered; UIElement editorWithTextUIElement = element.GetAncestor(typeof(EditorWithTextUIElement)); if (null != editorWithTextUIElement) combo.PerformAction(UltraComboAction.Dropdown); }
The code works perfectly. Can you take a look at the code below? It works for me too. Is it doing the right thing?
Dim clickedElement As UIElement = cboVendorName.UIElement.ElementFromPoint(New Point(e.X, e.Y))
If clickedElement IsNot Nothing AndAlso TypeOf clickedElement Is EditorWithTextUIElement Then
If Not cboVendorName.IsDroppedDown Then cboVendorName.ToggleDropdown()
Yeah, that's fine. It's essentially the same thing I did. My code is a little more efficient, using LastElementEntered and also a little more forgiving, since I am calling GetAncestor to get the proper UIElement. But it's unlikely to ever make any difference in the real world.