I'm changing the items on a combo-box dynamically. It's working perfectly, except that the number of visible rows remains fixed according to the first time the combo-box is clicked.
Example: The combobox items are set to A and B. When I click the combobox, it shows 2 rows with A and B.
Then I change dynamically the items to C, D and E. When I click the combobox, it shows 2 rows with C and D and a scrollbar.
I already set the
comboBox.setVisibleRowCount(10);
but it keeps showing only 2 rows and a scrollbar.
If I do the opposite, first set the items to C, D and E and click the combobox; it shows the three visible rows.
Then I change dynamically the items to A and B. When I click the combobox, it shows 3 rows! A, B and a blank row.
Try this:
box.hide(); //before you set new visibleRowCount value
box.setVisibleRowCount(rows); // set new visibleRowCount value
box.show(); //after you set new visibleRowCount value
It's works for me.
There is an issue already submitted in Javafx issue traker. https://javafx-jira.kenai.com/browse/RT-37622
It only works if the combobox has a fixed cell size. I did that with css.
for example:
.combo-box .list-view .list-cell{
-fx-cell-size: 35;
}
Here's at least a workaround: after changing the number of items, also change visibleRowCount to something else and back to your desired value. This seems to trigger an update of the dropdown height, although it was not always accurate in my tests.
Also, if you change visibleRowCount to 10, effectively nothing happens because this is the initial value and setting it to 10 does not invalidate the property.
Related
In my (not binded) DataGridView some cells are editable, and some are not.
When I click on an editable cell the focus goes there and i can write anything.
Then, if i press the key TAB the focus goes to the next cell.
But if the entered value is not valid, i can check the value from the event Grid_CellValidating and cancel the change using e.Cancel = True . If I do so, the focus stays in the same cell waiting for a valid value, instead of changing the current cell.
Until here all works as expected.
What I need now is, from a new modal window where I can select a value, set this value to a cell of the grid in the parent form and close the modal window.
This works, but I don't want just set the value to the cell. I want also to set the cell in "editing mode". I mean by "editing mode" that state where the cell content is selected and if you try to change the value, the event Grid_CellValidating fires and if the value is not valid, the logic in the Grid_CellValidating event can check it to decide if it's valid or not...
I didn't succeed with that.
This is the code I'm trying to use to make it work.
myGrid.Rows(myGrid.Rows.Count - 1).Cells("EID").Value = 1
myGrid.Focus()
myGrid.CurrentCell = myGrid("EID", myGrid.Rows.Count - 1)
myGrid.BeginEdit(True)
But this definitely does not work.
In fact, the focus is not even on the Grid. I can see the value 1 in the cell but the focus is not there. For example, if I press the key TAB I can see that the focus is on another control, not in the Grid.
What I expect is: If the value 1 is not valid, the event CellValidating fires and do the work...
Do you know what should I do to get the behavior I need?
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.
Friends,
I have a WPF Combobox. When the Combobox is opened, I have the items dynamically generated based upon environment variables. So basically a combobox that is bound to a list that is dynamically changing.
Everything works as expected until I Exit the combobox with the dropdown open to enter another control(another combobox).
When I reopen the first combobox, the items appear to be frozen and no longer bound to the list when INDEED the list is changing and is still bound. Its almost like the binding broke.
When this event occurs, I have attempted to forcefully add items, and that doesn't work either. I can see in the code behind that the combobox now contains the additional items, yet it doesn't appear that contain them in the UI.
What is this black magic? Any way to prevent it? is this some type of Stuck focus issue? Maybe the dropdown isn't re-sizing?
I think i have narrowed it down to the physical dropdown is not re-sizing to the new items.
EDIT*
The controls are dynamically generating, so I have no real hard code to show you other than this.
private void CBControl_DropDownOpened(object sender, EventArgs e)
{
((ComboBox)sender).Items.Add("Option");
}
On this event, I will add an items to the combobox, although the items ARE being added to the list, they are not displayed in the UI.
EDIT 2*
I figured it out, so i have 2 comboboxes, it appears that the 2nd was steeling and holding the focus INSIDE the dropdown. (odd bug)
in order to fix it i needed to release it bu changing the index of the 2nd combo box WHILE it is open.
int sel = ComboBoxTwo.SelectedIndex;
ComboBoxTwo.IsDropDownOpen = true;
ComboBoxTwo.SelectedIndex = -1;
ComboBoxTwo.IsDropDownOpen = true;
ComboBoxTwo.SelectedIndex = sel;
and I had to manage the unintended recursive call.
So, here it is.
You got 2 ComboBoxes. If you Open one then directly click into another, the focus is moved to the second combobox dropdown.
If you make any changes to the first combobox, the changes will not take effect to the style(dropdown resize) UNTIL you release the focus from the 2nd combo box dropdown item. Although the items change will take effect, the resize wont.
to release the focus, you need to open the second combox and change the selected index like so:
int sel = ComboBoxTwo.SelectedIndex;
ComboBoxTwo.IsDropDownOpen = true;
ComboBoxTwo.SelectedIndex = -1;
ComboBoxTwo.IsDropDownOpen = true;
ComboBoxTwo.SelectedIndex = sel;
10 hours of debugging. 5 hours of research. First solution I have found. It may be dirty, but its all I can find.
I am having a Datagrid that gets populated with values from a DataTable. In my program i have four buttons: Goto First, Last, Next and Previous, as the name name indicates i have to select the rows based on the selection made using these buttons. Everything seems well if i use the below code to get the row (for example first row).
DataGridRow row =(DataGridRow)userControl.m_DataGrid.ItemContainerGenerator.ContainerFromIndex(0);
row.IsSelected = true;
But the code throws null value when there is more rows than the height of the Datagrid(When scrollbar comes into picture).
Please help me out of this issue. I think this is because of the view problem.
Due to virtualization the containers are only created when the object is in view, so you could first scroll the item into view using the respective method, wait for the creation of the container and then select it.
As this is rather messy i would suggest binding the IsSelected to a property on your item using a style for DataGridRow (set it as ItemContainerStyle). Then you can just set the property to true and scroll the item into view if need be.
I have an Ext.grid.EditorGriPanel which has an combobox editor in its columnModel (the store of combox has just only 2 items: enabled/disabled). When a new blank row is inserted to grid, I want the combobox in that column have to be set to a default value (enabled), and the dropdown is not expanded.
I've tried to use
grid.colModel.columns[2].editor.select(0)
to get the combobox editor and set "enabled" value for it, but it did not work. Another way is using grid.colModel.columns[2].getCellEditor(rowIndex), but it returns an EditorGrid (I was so surprised because the ExtJS 3.3.1 API doesn't have this component).
Could you please help me on this problem?
Thank you so much!
When a new blank row is inserted to
grid, I want the combobox in that
column have to be set to a default
value (enabled), and the dropdown is
not expanded.
When the new record is inserted to the grid's store, the value of your column (in the record) needs to be set to "enabled". I'm not sure if you are doing it like this currently? In other words, the value must not be set to the editor of the column. Set it directly in the record.
(Also, you can define default values to be used for all records using the recordType property of the store - see ExtJS API documentation for more details - but this is optional.)
Finally, note that the combobox will not be displayed immediately after the row is added. The combobox is displayed only when you start editing that particular cell - this is the way EditorGrid works in ExtJS. But at least you should get the new row to immediately display the correct value ("enabled") with this advice.