A combobox in our application should show fixed-width and non-fixed-widths font names. I want to add an unselectable separator between them:
-- Fixed-width fonts --
Courier New
Lucida Console
...
-- Non-fixed-width fonts --
Arial
...
Is that possible with SWT?
The short answer is no. Neither Combo nor CCombo allow to flag items as unselectable.
But it should be possible to implement a custom combo widget that can show unselectable items with reasonable effort.
If you look into the CCombo code you will see that it is not a native widget but composed of other SWT widgets. It uses a List as the drop-down control to display the items.
If you use a ScrolledCompposite for the drop-down widget, you could place Labels therein to represent items. Unselectable items wouldn't require extra work. For selectable items, you could use mouse listeners for the Labels to highlight them when hovered and to handle selection.
If you plan to show a large number of items (which you shouldn't anyway in a combo box), the number of created labels may have a performance impact.
Alternatively, you may want to try the Nebula TableCombo. Possibly the table can be tweaked to show some items as unselectable (using custom-drawn items) and the selection behavior can be disabled for those.
Related
I'm trying to create a wpf combobox where certain keywords in the item text are always a different color (eg, phrase "abc" should always be blue, even if it's just a part of a longer word). Ideally, this should apply to all templates of the combobox: selected item, dropdown items, and the editing textbox as the user is typing new entries ("IsEditable" is set to true).
My initial thought is to use rich text controls for the templates of the combobox, but I'm having difficulty figuring out how to set the editing template. Even then, I'm not sure how to proceed on enforcing keyword coloring as the user types. Suggestions?
I'd like to have a combobox where there is a lot of information in the list to select from or search but only parts of it are shown after selection.
For example when the user starts typing "raf" the combobox should show a list like this:
RA - Raffael (raffael#example.com)
HU - Hugo (hugo#rafferty.xyz)
After selecting the entry "Raffael" only "RA" should be shown in the combobox.
I need that because of the limited space for the combobox in my application. So the combobox should not be wider than needed to hold some characters but the list to select from may be much wider. Is there an easy way to achieve that? Or which function i have to overwrite in combobox to set the text line after the selection?
Thanks
This is not possible with a standard Vaadin ComboBox without custom client side coding.
I'm using infragistics WPF editors and XamComboEditor. In previous WinForms version there was MRU list capability. What it basically does is it displays list of most recently used items at the beginning of the list and separates those items with some separator (which cannot be selected). Regular list of combo box items follows after this separator.
Now, infragistics combo does not provide this functionallity. I'll have to develop it on my own and the question is how to approach this. My biggest concern is how to modify current combo box (it can be regular wpf one) to actually display it.
Any suggestions are welcome.
To handle the actual UI part you can use CollectionViewSource/ICollectionView's Grouping and optionally Sorting (if you want the MRU to be ordered) to modify the ComboBox's view of the collection. Most of the work is going to be setting up the data which will be specific to your situation but all you'll need to do in the UI after you're bound to a grouped ICollectionView is set a GroupStyle on the ComboBox where you probably want to show a separator only for the non-MRU group and nothing for the MRU.
I've written an 'auto-suggest' textbox user control in WPF. It behaves a little bit like the 'To' list in Hotmail, allowing the user to enter a list of items, offering suggestions when it is able.
The main controls are a a text box, a wrap panel and a list box. The text box captures user input. The wrap panel contains the text box and shows previous entries. The list box is used to show suggestions. Most of the time, the list box is hidden.
I'm using multiple instances of my control in a stack panel.
My problem is that when the list box is shown, it is included in the measurement of the height of the control. This forces the following controls in the stack panel to be shifted down, as these pictures demonstrate:
alt text http://img13.imageshack.us/img13/8366/example1a.png
alt text http://img208.imageshack.us/img208/7664/example2a.png
I've tried overriding the measurement of my control so not to include the list box, but this just results in the list box not being visible.
What I want to do is make the list box overlay any subsequent controls in the stack panel, like a combo box's drop down would do. However, I really don't know how to do this. Any ideas?
Thanks
Sandy
You might want to have a look at the Popup control. That is what the ComboBox uses to display its options. Good luck!
Try this instead of your text box / list box combination: A Reusable WPF Autocomplete TextBox
I have a Silverlight form that contains a Stack Panel (orientation = vertical) with 10 rows. Each row contains a TextBlock and Textbox control except the last row has a TextBlock and Drowdown.. At the bottom of the control are two buttons. Previous & Continue.
There are 10 items in the Dropdown. When I select a value from the Dropdown, only two of the ten items are showing up. I believe that the remaining items aren't displying because there's some sort of clipping effect going on. Fair enough.
Does Silverlight allow the dropdown control to display upwards (instead of the default down direction)? Will I have to override some rendering capabiliities before the dropdown is rendered to the control or is there a property that allows me to accomplish this functionality?
The Silverlight ComboBox auto aligns the dropdown popup to always be visible whenever possible.
all Popup based controls (ComboBox, AutoCompleteBox, DatePicker and TimePicker) all have this feature enabled.
So if there's not enough screen real-estate below the ComboBox to show the dropdown popup, it'll show up above the control.
The combobox nesting in the visual tree should not affect the dropdown popup auto alignment. The internal Popup control (inside the ComboBox) ignores the Visual Tree and is nested "above" the visual tree.
If you have specific issues, please share minimal and relevant XAML. Since Keith is on this thread, I think it's safe to say he'll log a bug if needed.