combobox

Combo or drop-down box where user can enter own value as well?

血红的双手。 提交于 2019-12-20 06:10:17
问题 Can you have a combo or drop-down box where the user can either choose from a list of given alternatives, or enter their own value? 回答1: Yes, this is a feature of the standard ComboBox control. Its precise behavior depends on the value you set for the control's Style property. Here's a quick run-down of the options: vbComboDropDown is the default style. The combo box looks like a single-line text box with a drop-down arrow. The user can either type arbitrary text into the text box, or they

Can't get the cascading combo boxes to work

只谈情不闲聊 提交于 2019-12-20 06:04:30
问题 I am trying to make cascading combo boxes but I can't seem to get it to work. For example, if I select a specific computer in the first combo box, then the second combo box should only show the HDD that is compatible with that computer. I also provided a link to the database that I have created. Can anyone help me out with this? I have 2 tables with the fields: tblComputer(Computer) tblHDD(HDD, Computer) cboxComputer Row Source: SELECT tblComputer.Computer FROM tblComputer; cboxHDD Row Source

Remove Items from Collection in a loop (Combo Box items)

雨燕双飞 提交于 2019-12-20 05:38:06
问题 I am trying to remove all items from a combo box list that begin with "~$". For Each item As String In cstmcmbxDocs.Items If Not cstmcmbxDocs.Items.Contains("~$") Then Dim STR As Int16 = cstmcmbxDocs.FindString("~$") 'gets the index of the item which contains "~$" cstmcmbxDocs.Items.RemoveAt([STR]) End If Next But it only returns one instance which it removes. It doesn't continue searching - what am i missing here? (Note that I am using 3.5 and not 4+ because it needs to be compatible with XP

Can one bind a combobox Itemssource from a datatemplate of a ItemsControl

限于喜欢 提交于 2019-12-20 05:31:59
问题 Given ComboBox in the ItemsControl will have different items which is based on the DataContext of the item (not of the ItemsControl ). Can it be done? And how? Preferably from code behind. I have the following DataModel : class Tester { public Tester(string name, string surname) { Name = name; Surname = surname; } public string Name { get; set; } public string Surname { get; set; } public override string ToString() { return Name + " " + Surname; } } class TheT { public ObservableCollection

Binding WPF combobox to a user settings property

允我心安 提交于 2019-12-20 05:23:33
问题 I've a combobox in WPF with 4 static values in it: <ComboBox SelectedValue="{Binding Source={x:Static properties:Settings.Default}, Path=KeyModifier, Mode=TwoWay}"> <ComboBoxItem>Alt</ComboBoxItem> <ComboBoxItem>Shift</ComboBoxItem> <ComboBoxItem>Ctrl</ComboBoxItem> <ComboBoxItem>Win</ComboBoxItem> </ComboBox> I want to connect the selected value of this combobox with a simple string property in the user settings. That works half way: The selected value is perfectly written to Settings

WPF Adding a ComboBox to a DataGrid or List View Based on different DB Tables

故事扮演 提交于 2019-12-20 04:38:22
问题 I would like to add a ComboBox to a DataGrid or ListView but the Combobox's underlying ViewSource would be filtered by data from each row's DataRowView of the DataGrid . Example: A list of companies and some information about the company is displayed in a DataGrid / ListView . The companies listed may have several phone numbers. I want the phone numbers to be in the ComboBox that is displayed with the companies information. The company information and phone numbers are in different tables and

How to delete object from combobox?

☆樱花仙子☆ 提交于 2019-12-20 04:16:28
问题 I have a combobox with objects of Foo type, here is the Foo class: public class Foo { public string name { get; set; } public string path { get; set; } } The Foo.name is the displayed text in the combobox and Foo.path is the value of the selected option. I want to delete an option from the combobox after some operation I made. I've tried these ways: 1 comboBox2.Items.Remove(@comboBox2.Text); 2 comboBox2.Items.Remove(@comboBox2.SelectedValue.ToString()); 3 Foo ToDelete = new Foo(); ToDelete

Dynamically Populate ComboBox Within A WPF ListView With Items

折月煮酒 提交于 2019-12-20 04:13:43
问题 I have a WPF ListView which is bound to a data source. In the ListView are dynamically created ComboBoxes, which I would like to bind to another data source to provide the Items, but the SelectedIndex comes from the first data source (see XAML below). Currently, the functionality works fine if the ComboBoxItems are coded statically into the XAML (shown commented out in the XAML below). But, I want to provide the ComboBoxItems (list of strings) dynamically, so I can expand the list, by either

How to prevent controls from capturing KeyDown events while a modal form is open?

馋奶兔 提交于 2019-12-20 04:07:11
问题 I have a form with CancelButton and AcceptButton (named btnCancel and btnOK). And I have some ComboBoxes as input fields. ComboBoxes prevent my AcceptButton and CancelButton to receive Escape and Enter keys, so I added this code to KeyDown event for all fields: if (e.KeyData == Keys.Escape) { ComboBox field = (ComboBox)sender; if ((field.DropDownStyle == ComboBoxStyle.Simple) || (!field.DroppedDown)) { e.SuppressKeyPress = true; btnCancel.PerformClick(); } } else if (e.KeyData == Keys.Enter)

combobox focus on beginning of text after selection

自作多情 提交于 2019-12-20 03:17:23
问题 I'm using winforms with a combobox that has a wider drop down width than it's size. when a user selects something from there, it displays just the ending of the text instead of the beginning. how do i default it to show text starting with the start of the string? ie. combobox has items Atlanta Georgia Athens Georgia Miami Florida .... and the user picks one and all they see in the box afterwards is "a Georgia" no, i unfortunately don't have the realestate to make the combobox bigger, and the