combobox

Display “Select an item” in Combobox when selectedItem is null

痞子三分冷 提交于 2020-01-04 12:47:14
问题 I have a WPF Combobox that is bound to a list of viewModel objects. Initially the SelectedItem is null, and thus the Combobox display is blank. When the selected item is null, I would prefer the Combobox to display "Select an item" to guide the user to select something from the combobox. sort of like the way, some text boxes contain gray text such as "enter user name" Any ideas on how to do this? Edit: I ended up using the suggestion to overlay a textbox, and change its visibility based on

remove combobox selected item text highlighting

孤者浪人 提交于 2020-01-04 05:29:30
问题 I've already found a lot of questions about manipulating the highlight of items to select in the dropdown of the combobox or overriding system brushes. This is NOT what I'm after.. I want to get rid of the text highlighting of the selected item shown in the combobox textfield after selecting. But I do not want to get rid of the text highlighting in the dropdown! So overriding the system brushes is not what I need because that also affects the items in the dropdown. Below is XAML for a

Combobox displaying duplicate items

丶灬走出姿态 提交于 2020-01-04 05:18:16
问题 I have a combo box that I am binding from a sql server database. I am binding one column from the database into the combo box. The problem is that I get the same item showing up in there several times. I am querying from a stored procedure. Let me know if there is anything obvious that I am missing. Thanks public void BindComboBox() { _dsinventory = new DataSet(); _dsinventory = dbAccess.ExecuteQuery(InventoryOutputQuery.ComboBox_Type()); cmbType.ItemSource = _dsinventory.Tables[0]

Combobox displaying duplicate items

北城余情 提交于 2020-01-04 05:18:09
问题 I have a combo box that I am binding from a sql server database. I am binding one column from the database into the combo box. The problem is that I get the same item showing up in there several times. I am querying from a stored procedure. Let me know if there is anything obvious that I am missing. Thanks public void BindComboBox() { _dsinventory = new DataSet(); _dsinventory = dbAccess.ExecuteQuery(InventoryOutputQuery.ComboBox_Type()); cmbType.ItemSource = _dsinventory.Tables[0]

How to hide enum values on a combo box at runtime?

偶尔善良 提交于 2020-01-04 03:14:47
问题 Suppose the combobox is linked to enum "ABC". The elements in it are A, B C and D. Now I need to get only A and C in the combobox and not B and D? Is this possible? 回答1: It is not possible to delete enum values or combobox values. You can duplicate the enum, then delete elements or change the order (but not the enum value). It will be your responsability to maintain both enum types synchronized with future changes. To assign an enum to another incompatible enum, just add zero to it! abc =

WPF: Change background on some combobox items

夙愿已清 提交于 2020-01-04 02:32:05
问题 I'm trying to change the background of certain items in a combobox that meet a condition <ComboBox ItemsSource="{Binding Path=Model.Names, Mode=OneWay}" SelectedValue="{Binding Path=SelectedCompanyName}" DisplayMemberPath="Alias" /> The thing is that "Alias" is saved in two different places (in company and in order) and if they dont match we want to highlight this. I want to do something like this: <Style>... <DataTrigger Binding="{Binding Path=isMismatch}" Value="True> <Setter Property=

How to get the selected item from a ComboBox in JavaFX?

混江龙づ霸主 提交于 2020-01-03 20:03:11
问题 i have ComboBox cbx and a TabPane Contains Tabs (tab: t ) and a button b1 . So on click on this button b1 , it adds a new tab t in the TabPane and it adds a new item in the ComboBox cbx contains the same name of the tab. The problem is i don't know how to get the item from cbx and much the name of the item with the same name of the tab and then Do something so how i can do this with javafx and thanks very much :) 回答1: Take a look at the API: http://docs.oracle.com/javase/8/javafx/api/javafx

How to get the selected item from a ComboBox in JavaFX?

只谈情不闲聊 提交于 2020-01-03 20:02:07
问题 i have ComboBox cbx and a TabPane Contains Tabs (tab: t ) and a button b1 . So on click on this button b1 , it adds a new tab t in the TabPane and it adds a new item in the ComboBox cbx contains the same name of the tab. The problem is i don't know how to get the item from cbx and much the name of the item with the same name of the tab and then Do something so how i can do this with javafx and thanks very much :) 回答1: Take a look at the API: http://docs.oracle.com/javase/8/javafx/api/javafx

ComboBox strange behaviour (JavaFX 8)

扶醉桌前 提交于 2020-01-03 18:19:23
问题 I have this code in start method: ObservableList<StringBuilder> list = FXCollections.observableArrayList(); list.add(new StringBuilder("0")); list.add(new StringBuilder("1")); list.add(new StringBuilder("2")); list.add(new StringBuilder("3")); list.add(new StringBuilder("4")); list.add(new StringBuilder("5")); list.add(new StringBuilder("6")); list.add(new StringBuilder("7")); list.add(new StringBuilder("8")); list.add(new StringBuilder("9")); ComboBox<StringBuilder> combo = new ComboBox<>

How to add items to Combobox from Entity Framework?

半城伤御伤魂 提交于 2020-01-03 16:53:48
问题 I have this code: private void FillCombobox() { using (InventoryEntities c = new InventoryEntities(Properties.Settings.Default.Connection)) { List<Customer> usepurposes = c.Customers.ToList(); DataTable dt = new DataTable(); dt.Columns.Add("id"); dt.Columns.Add("name"); foreach (Customer usepurpose in usepurposes) { dt.Rows.Add(usepurpose.id, usepurpose.name); } comboBox1.ValueMember = dt.Columns[0].ColumnName; comboBox1.DisplayMember = dt.Columns[1].ColumnName; comboBox1.DataSource = dt; } }