combobox

WPF: Raise programmatically a SelectionChangedEvent

倖福魔咒の 提交于 2021-02-07 14:48:58
问题 in WPF, I want raise programmatically a SelectionChanged event on a combobox. I've tried the following code but it doesn't work: myComboBox.RaiseEvent(new RoutedEventArgs(ComboBox.SelectionChangedEvent, myComboBox)); How can i raise that event? Thanks 回答1: While the other answers here are good practice, they don't actually answer your question. To actually answer your question of programmatically raising a SelectionChangedEvent, you could do something like the following: RoutedEvent routed =

WPF: Raise programmatically a SelectionChangedEvent

喜你入骨 提交于 2021-02-07 14:44:25
问题 in WPF, I want raise programmatically a SelectionChanged event on a combobox. I've tried the following code but it doesn't work: myComboBox.RaiseEvent(new RoutedEventArgs(ComboBox.SelectionChangedEvent, myComboBox)); How can i raise that event? Thanks 回答1: While the other answers here are good practice, they don't actually answer your question. To actually answer your question of programmatically raising a SelectionChangedEvent, you could do something like the following: RoutedEvent routed =

How do you cast an object to a Tuple?

徘徊边缘 提交于 2021-02-07 11:18:21
问题 I create my Tuple and add it to a combo box: comboBox1.Items.Add(new Tuple<string, string>(service, method)); Now I wish to cast the item as a Tuple, but this does not work: Tuple<string, string> selectedTuple = Tuple<string, string>(comboBox1.SelectedItem); How can I accomplish this? 回答1: Don't forget the () when you cast: Tuple<string, string> selectedTuple = (Tuple<string, string>)comboBox1.SelectedItem; 回答2: Your syntax is wrong. It should be: Tuple<string, string> selectedTuple = (Tuple

Get the ComboBox that a ComboBoxItem resides in

断了今生、忘了曾经 提交于 2021-02-07 08:13:48
问题 I need to find the ComboBox that a ComboBoxItem resides in. In codebehind I catch an event when a ComboBoxItem is clicked, but I don't know which one of several ComboBoxes that the specific ComboBoxItem belongs to. How do I find the ComboBox? Normally you can use LogicalTreeHelper.GetParent() and traverse up the logical tree from the ComboBoxItem to find the ComboBox. But this only works if the ComboBoxItems are added to the ComboBox manually, not when the items are applied to the ComboBox

Javafx combobox not updating dropdown size upon change on realtime?

淺唱寂寞╮ 提交于 2021-02-06 11:33:53
问题 I am using Javafx v8.0.25-b18. The problem I occur is that the size of the dynamic combox's dropdown list doesn't change, so if I had initially two items in the dropdown, then the dropdown size will be good for two items, but if I now populate the dynamic combox with three items then I get a small scrollbar inside!?, If I remove an item - I will have a blank space in the combox !? I want to "reset" the dropdown size each time I put values into it, so it will be the right size each time it

How to fill combobox with Datatable column C#

Deadly 提交于 2021-02-05 11:22:51
问题 I'm trying to add items to a combo box using a data table that already has some columns but I just want one of them values into the combo box. What i'm doing is this: cbReviewers.DataSource = Reviewers_table.Columns[1]; but is not working, do you know how could I do it? 回答1: I think you need to use Display and Value members properties to work with display data. cbReviewers.DataSource = Reviewers_table cbReviewers.DisplayMember = "ColumnNameThatContainsText" cbReviewers.ValueMember =

getting selected value of Combobox python

血红的双手。 提交于 2021-02-05 11:15:36
问题 Hi I have the following code def create(self): geo = StringVar() city = ttk.Combobox(gui, textvariable=geo,state="readonly") city.config(values=self.geo) city.pack() city.bind("<<ComboboxSelected>>", self.cityselection) def cityselection(self,event): selected=event print(selected) I want to send the selected value of from the Combobox to cityselection function but when I print it I only get VirtualEvent event x=0 y=0 and it does not matter which value I choose I will always get the above

getting selected value of Combobox python

筅森魡賤 提交于 2021-02-05 11:14:27
问题 Hi I have the following code def create(self): geo = StringVar() city = ttk.Combobox(gui, textvariable=geo,state="readonly") city.config(values=self.geo) city.pack() city.bind("<<ComboboxSelected>>", self.cityselection) def cityselection(self,event): selected=event print(selected) I want to send the selected value of from the Combobox to cityselection function but when I print it I only get VirtualEvent event x=0 y=0 and it does not matter which value I choose I will always get the above

How to change the background color of a selected ComboBox item? uwp

非 Y 不嫁゛ 提交于 2021-02-05 08:09:14
问题 I'm developing an application for a Windows 10 Mobile device and I'm struggling to handle the styling for the ComboBox control, more specifically, the selected item's background color. Without editing the Foreground or Background properties of the control; How the ComboBox is displayed prior to selecting any items: The expanded ComboBox The ComboBox with "2" as the selected item I can't seem to find any properties for the control such as SelectedItemBackgroundColor and changing the Foreground

Change width of dropdown listbox of a ttk combobox

家住魔仙堡 提交于 2021-02-05 04:45:39
问题 I am trying to change to width of the popdown list of the ttk Combobox. Setting the width of the Combobox also changes the width of the Listbox, making part of the values unreadable. I read this solution in Tk/Tcl but I am not familiar with this language and would like to solve the problem with Python. I tried changing the theme parameters but it does not seem to help. Below is a piece of sample code. import tkinter as tk from tkinter import ttk root = tk.Tk() root.title("testing the combobox