combobox

WPF ComboBox update source

孤街浪徒 提交于 2019-12-13 16:13:36
问题 I have a ComboBox with country codes and phone numbers (+43.., ..) The ItemsSource is a list of Country objects with many properties (Code is one of them.) The DataContext in which the ComboBox is located is an object with the PhoneNumber property. When user selects a country in the list, I want to update the source PhoneNumber Property(which is a string) with the '+43' value from the Country object. The list appears, but the source is never updated. How to do that? When I replace it with

Databinding bindinglist to combobox and removing items

六眼飞鱼酱① 提交于 2019-12-13 16:06:22
问题 I am trying to use windows forms databinding to hook up a combobox to a ViewModel class. var items = new BindingList<Person>(); comboBox.DataSource = items; comboBox.DisplayMember = "Name"; All works ok except when I remove items from the list. For example if I remove the currently selected item (selected in the combobox) the selectedIndexChanged and SelectedValueChanged events of the combobox don't fire. 回答1: Found an answer. I had to use a BindingSource as middleman var bindingsSource = new

How to open a Vaadin ComboBox by code?

点点圈 提交于 2019-12-13 15:25:56
问题 Is it possible to open a Vaadin ComboBox by code? I'd like to present 2 comboboxes that depend on each other. When the user selects a value in the first, I'd like the 2nd combobox to automatically open the possible selections, so that the user can directly select one, instead of having to open the 2nd combobox himself. Maybe there is an event that I could send to trigger the opening? 回答1: The only thing I can think of is, after giving focus to the combobox, try sending it a keystroke (ie the

How to Set default combobox

丶灬走出姿态 提交于 2019-12-13 11:53:32
问题 So I've been looking to set a default value for my combobox. I found a few things but none of them seem to work. Actually, it works if I create a simple combobox and use comboBox1.SelectedIndex = comboBox1.Items.IndexOf("something") but once I dynamically generate the contents of the comboboxes, I can't get it to work anymore. This is how I fill my combo box (located in the class's constructor); string command = "SELECT category_id, name FROM CATEGORY ORDER BY name"; List<string[]> list =

C# Enable/Disable multiple textbox based on combobox selection

旧城冷巷雨未停 提交于 2019-12-13 11:08:02
问题 I am just an ordinary guy who is learning how to code. I don't like when code looks sloppy and can be consolidated. With that being said I need to consolidate some code, but I have failed to find information on how to do it. I am trying to enable/disable multiple textbox based of combobox selection. Here is the long and ugly code I am trying to consolidate private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { int Combobox_Process_Selected_Index = comboBox2.SelectedIndex;

C# comboBox without dropDown [closed]

橙三吉。 提交于 2019-12-13 11:02:37
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have ordinary combobox and I want to prevent any changes on it, so I want to make it not show dropdown. Is it possible? I've tried changing dropDownStyle to simple, but then it shows list of items below. 回答1:

Two combobox with same ItemsSource of ObservableCollection<ComboBoxItem>

爱⌒轻易说出口 提交于 2019-12-13 10:57:15
问题 <ComboBox Grid.Row="0" ItemsSource="{Binding Path=optList}" IsSynchronizedWithCurrentItem="False" /> <ComboBox Grid.Row="1" ItemsSource="{Binding Path=optList}" IsSynchronizedWithCurrentItem="False" /> public ObservableCollection<ComboBoxItem> optList{ get; set; } = new ObservableCollection<ComboBoxItem>() { new ComboBoxItem() { Content = "1"}, new ComboBoxItem() { Content = "2"} } When I am switching between comboboxes then one dropdown become empty. Do you know why? It is working with

How to populate days combobox based on month and year?

和自甴很熟 提交于 2019-12-13 10:28:34
问题 private void buildMonthsList(cmbMonth monthsList) { for (int monthCount = 0; monthCount < 12; monthCount++) monthsList.addItem(Const.MONTHS[monthCount]); } public boolean DaysComboBox (int year) { Calendar cal = Calendar.getInstance(); int months = cal.get(Calendar.MONTH); year = (int) cmbYear.getSelectedItem(); boolean leap = false; if(year % 4 == 0) { if( year % 100 == 0) { // year is divisible by 400, hence the year is a leap year if ( year % 400 == 0) { leap = true; } else { leap = false;

How do you assign different data sources for a DataGridViewComboBox for each record?

十年热恋 提交于 2019-12-13 09:48:00
问题 I have a winforms DataGridView that I wish to have a column containing comboboxes for each record. Each combobox will have completely different values for each row and need to be assigned a datasource during the databinding of the DataGridView. I can assign 1 datasource to all (that's easy), but having each combobox have different values looks impossible). Here's what I'm working with - note: The datasource of the DataGridView is defined programmatically by setting a property from the calling

ComboBox crashing WPF application because SelectionChanged is firing too soon

北城以北 提交于 2019-12-13 09:31:00
问题 Here's my XAML: <ComboBox x:Name="cloneSelector" Width="80" SelectedIndex="0" VerticalAlignment="Top" Margin="10" SelectionChanged="cloneSelector_SelectionChanged"> <ComboBoxItem Content="All" /> <ComboBoxItem Content="Top" /> <ComboBoxItem Content="Middle" /> <ComboBoxItem Content="Bottom" /> <ComboBoxItem Content="None" /> </ComboBox> And here is the SelectionChanged handler (as requested by a comment): cloneSelection = (CloneFormat) cloneSelector.SelectedIndex; var frameSize = videoDevice