Vaadin 8 Combobox howto selected fist item - combobox

I tried the following:
machineComboBox.setEmptySelectionAllowed(false);
machineComboBox.focus();
this.addComponent(machineComboBox);
I read:
Cannot set focus on combobox inside a grid

What exactly you are trying to achieve? If you simply want to select the first item, then this should work:
machineComboBox.setSelectedItem(yourItems.get(0));
Example is taken from here : Selection Components
focus() doesn't select anything, only focuses (outlines) the component.

Related

Codename One ComboBox how to highlighting already selected value

We are able to create ComboBox and populating data too. But we need to highlighting already saved values. Can you please suggest code for this.
Our requirement is if Combobox has 1,2,3. If I select 2 and save. We need to set the combo box value 2 in such way that when we open the Combobox need to display this 2 as highlight value along with 1,2,3 values.
Simply same as select box option selection.
I would generally recommend avoiding ComboBox altogether.
Assuming this isn't an option you will need to define a renderer and disable the OS specific 2 render mode using a theme constant:
otherPopupRendererBool=false

Combobox List passing string

I have a VB6 application that has been running for quite sometime. Currently I'm trying to update one of the form that has a combobox 2.0. Because the combobox is populated with hundreds of items - I'm trying to update it so that users are able to click on a look up button next to it, where another window opens up with all the items from the combobox. User will be able to search by keyword and/or select an item and double click on it and have it appear in the combobox. The issue I'm having is with trying to pass no value or "" when CANCEL is clicked. I'm able to pass the value if I in the properties window my STYLE Is set to COMBO rather than list. However, the issue I come across is that with COMBO the value (text) in the combobox sometimes is not aligned properly. Is there a way to pass a "" value to a combobox 2.0 without changing the style to COMBO?
If they hit cancel set the ListIndex of your combo to -1 rather than setting the text property. This is the value for no item being selected.

How to add CheckBoxes to a ComboBox?

I want to create a ComboBox having Checkboxes as children using Codename one.
I am not using the UIBuilder
For reusability I created a Container having three Checkboxes in it:
OverviewCheckBoxContainer
- Checkbox1
- Checkbox2
- Checkbox3
and this works already.
As it takes too much space on the screen, I now tried to add the CheckBoxContainer into a Combobox, like this:
ComboBox
- OverviewCheckBoxCont
-...
but it does not work, the ComboBox contains a single entry only and it's not a checkbox, but a text:
OverviewCheckBoxCont[x=...
(cannot see further on the screen)
How can I solve this issue, so there is a dropdown menu containing the three Checkboxes, that toggle onClick?
ps:
In the main form I added the CheckBoxesComboBox instead of the CheckBoxesCont:
this.add(BorderLayout.CENTER, checkBoxesComboBox)
instead of
this.add(BorderLayout.CENTER, checkBoxesCont)
1.You can use simple combobox as shown below
ArrayList al = new ArrayList();
findComboBox().setModel(new DefaultListModel(al));
2.And to add checkbox in combobox , you have to customize the combobox
3.Instead of customizing combobox, You can use button which shows and hides OverviewCheckBoxContainer which contains list of checkboxs
See this for customizing the ComboBox with the generic list cell renderer: https://www.codenameone.com/manual/components.html#_combobox
The problem with using checkboxes in a combo is that you would assume they would all appear in the combo as a set and the combo wasn't designed to do that. I would instead just use a Button and show a dialog with a set of checkboxes then set the text of the Button to match the result. You can style the button to look like a ComboBox if that is your preference.

How to remove focus from the Infragistics ultragrid cell when clicking outside?

I have an infragistics ultragrid control in a windows form. There is an 'Add New' button outside to insert new rows to the grid.
The problem I faced is, when I click the button outside the grid, while I'm editing a cell inside the grid, the cell doesn't lose focus. Because of this the edited new value is not updated to its underlying data source.
I need this cell to lose focus and update it's underlying data source, because the 'Add New' button creates a new row with this particular column having a default value which is calculated based on the previous row's edited value.
So any ideas on how to unfocus the ultragrid cell? This situation may apply to normal GridView also.
If your button is on a Toolbar, then the behavior you are seeing is expected because toolbars don't take focus. If this is the case before performing your logic you can use the PerformAction method of the grid and pass in UltraGridAction.CommitRow to force the row that was being editor to commit its updates.
For example:
this.ultraGrid1.PerformAction(UltraGridAction.CommitRow);
I used myUltraGrid.ActiveRow.Cells[0].Activate(); which also works. But the solution by #alhalama is better one I guess.

Not selecting item in combobox

I need the following behavior for WPF Combobox:
i need autofilter in combobox. Took the implementation from here. But when there are several items in dropdown that are almost same-when i press DOWN it just selects the first one from list and hides others(see video of current behavior here: http://www.youtube.com/watch?v=_WYAgMTxc4M). If i want the second possible-i have to select it with mouse or write down the whole item display name in editable part of combobox. Is it possible to select item without changing editable part of the combobox, until i press ENTER, for example?
I think that problem is when you select the item, it fill the text area of ComboBox, than it notify that filter text changed and it applied new filter for the list, and the only one item remains in the list.
You should to rewrite this behavior that will apply filter only if KeyPressed / KeyDown / KeyUp events was fired.

Resources