I apologize if this has been asked previously, my forum search didn't turn up any results.
I understand the standard behavior of the UltraCombo is this (note I'm only speaking about an editable combo)
1. Combo Text Value is empty. Click into text field to gain focus.
2. Click dropdown arrow. Drop down appears
3. Down arrow to next row in the list. The currently selected / active row value appears in the combo text field.
4. Down arrow to next row. Text value changes to the newly selected row.
5. Close drop down, text value remains.
Setting aside *why* I've been asked to do this, If I wanted the following behavior instead:
1. Combo text is empty. Click into text box to gain focus.
2. Click drop down arrow. First row in the drop down is active, but no value is show in the text box.
3. Click down arrow. Next row in the drop down is active. Still no value is shown in the text box.
4. Close drop down. Text box value is empty.
In a nutshell, I ONLY want the text portion of the combo to have a value IF either 1) the user pressed the enter key on a row or 2) the user clicked a row with the mouse.
Is this possible? I've been wrestling it for a few days.
Hi,
There's no way to do this with the built-in combo dropdown. You could create your own combo, though. There's a little work involved, but it's probably not as bad as you think. You can use a DropDownEditorButton and put a grid on it and then you just have to code the interaction between the two. There's some sample code here to get you started.
Chris,
Here is a sample application which I think does what you described. I am using an ultraTextEditor with an UltraGrid assigned as the Control of one of the ButtonsRight of the TextEditor. Look it over and let me know if you have questions. I hope this is helpful to you.
Christopher,
Did that sample work for you?
Hi Michael
Thanks for attaching the sample. I did attempt to use the approach you and Mike suggested. However, I struggled for 2 days trying to get the UltraGrid to size itself correctly. Because I have no way of knowing at design time how many rows / columns the grid will have, I can't hardcode the grid to a certain size.
I tried putting some code in the BeforeDropDown event on the button and attempting to calculate the necessary width to set the grid but I was never able to accurately set that value (sometimes it was too big, other times i got a horizontal scrollbar).
Even more cumbersome though was trying to duplicate the MaxDropDown property you get when using the UltraCombo. Even though I wasn't using the UltraCombo I still wanted / needed a way to specify x number of rows to show at a time in the UltraGrid. Trying to do this myself proved to be a nightmare.
After two days of flailing, I decided the effort wasn't worth it.
This can be very tricky, because depending on the settings and styling you are using, the cells may overlap and it's tough to account for borders and scrollbars. But in the simple example Mike posted above, this works:
private void ultraTextEditor1_BeforeEditorButtonDropDown(object sender, Infragistics.Win.UltraWinEditors.BeforeEditorButtonDropDownEventArgs e) { UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0]; band.PerformAutoResizeColumns(false, PerformAutoSizeType.AllRowsInBand, AutoResizeColumnWidthOptions.All); int requiredWidth = -1; foreach (UltraGridColumn column in band.Columns) { requiredWidth += column.CellSizeResolved.Width + 1; } this.ultraGrid1.Update(); var rowScrollbarUIElement = this.ultraGrid1.DisplayLayout.UIElement.GetDescendant(typeof(RowScrollbarUIElement)); if (null != rowScrollbarUIElement) requiredWidth += rowScrollbarUIElement.Rect.Width; this.ultraGrid1.Width = requiredWidth; }
I found this code worked fine in my sample. Have you tested it?