combobox

Display certain variable of each object into a Combobox

别来无恙 提交于 2019-12-13 02:27:25
问题 Quick question.. I have a List of objects of this class: public class Whatever { public string Name { get; set; } public List<blaBla> m_blaBla { get; set; } // .. } And I want to link the List<Whatever> to a ComboxBox, where the user sees the Name of each Whatever object. How can I do that? 回答1: You could either use ComboBox.ItemTemplate like this: C#: List<Whatever> lst = new List<Whatever>(); public MainWindow() { InitializeComponent(); cmb.ItemsSource = lst; } XAML: <ComboBox Name="cmb">

DataGridView ComboBox column not accepting new values

可紊 提交于 2019-12-13 02:25:44
问题 I have a DataGridView control in my Windows Forms application that allows users to edit product listing. To edit the product category, I want user to add new entries or select from the ones already entered before. To achieve this I added a comboBox column that is binded to a DataSource that gets the distinct category names from the products table. With the help of some other SO questions I was able make this comboBox editable using this code: private void dataGridView1_EditingControlShowing

WPF Combobox SelectedItem hell

一笑奈何 提交于 2019-12-13 02:21:19
问题 Im having a very funny issue in WPF Im creating a Combobox through code, and adding it to a control. When I set the Combobox.SelectedItem or Combobox.SelectedIndex or Combobox.SelectedValue I am unable to select another option from the Combox items. ForeignKeyDisplayAttribute attribute = (ForeignKeyDisplayAttribute)this.GetAttribute(typeof(ForeignKeyDisplayAttribute), property); if (attribute != null) { ForeignKeyDisplayAttribute fkd = attribute; Type subItemType = fkd.ForeignKeyObject;

Return the choice of a combobox javafx

心已入冬 提交于 2019-12-13 02:01:14
问题 I have an app with 2 ComboBox and I would like to return the choice of the user into a variable. How should I do it ? Here is my controller class : package ch.makery.adress; import java.awt.FileDialog; import javafx.fxml.Initializable; import java.net.URL; import java.util.ResourceBundle; import javax.swing.JFrame; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.ComboBox;

.NET WinForms combobox bindingsource and databinding question

岁酱吖の 提交于 2019-12-13 01:53:07
问题 I created the following class to model a person: namespace DataBindingTest { public enum colorEnum { Red, Green, Yellow, Blue, } class Person { private string _Name; private int _Age; private colorEnum _FavoriteColor; private bool _HasAllergies; public string Name { get { return _Name; } set { _Name = value; } } public int Age { get { return _Age; } set { _Age = value; } } public colorEnum FavoriteColor { get { return _FavoriteColor; } set { _FavoriteColor = value; } } public bool

Powershell Windows Form Multilevel Combo Box

无人久伴 提交于 2019-12-13 01:26:42
问题 I have a windows form built in powershell thats designed to give 3 comboboxes: CB1: Displays 5 Job descriptions CB2: When any option from CB1 is selected its matched using $ComboBox1_SelectedIndexChanged and then a switch statement CB3: When any option from CB2 is selected its matched using $ComboBox2_SelectedIndexChanged and then a switch statement In this image, i have selected "Commercial Directorate" and its showing me the first match in the list "branch property trusts" enter image

Excel - VBA Removing Duplicates from Comboboxes

泄露秘密 提交于 2019-12-13 01:26:00
问题 I am trying to create a subroutine to delete duplicates out of comboboxes. I input a number in place of X when I called the subroutine. I keep getting an error that tells me "Object Required" when i get to the subroutine. I know that means that something is not being properly initialized, but I cannot figure out how to fix my issue. Any help would be greatly appreciated. Thank you. Private Sub UserForm_Initialize() 'ComboBox Populate Dim rngNext As Range Dim myRange As Range Dim C As Integer

Repopulate a combobox itemlist without affecting what is currently written inside the combobox?

主宰稳场 提交于 2019-12-13 00:56:40
问题 How can I repopulate a combobox itemlist without affecting what is currently written inside the combobox? I currently have code that looks kind of like: Private Sub ComboBox1_DropButtonClick() Dim v As Variant Dim selText As String selText = ComboBox1.selText Dim i As Integer For i = 0 To ComboBox1.ListCount - 1 ComboBox1.RemoveItem (0) Next i v = Call CreateList() For i = 0 to Ubound(v) ComboBox1.AddItem v(i) Next v If selText <> "" Then ComboBox1.Text = selText End Sub I haven't worked with

Generic ComboBox in Windows Forms Application

放肆的年华 提交于 2019-12-13 00:52:05
问题 I need to have a class derived from ComboBox that will only accept Objects of some specific type. So, I need to have a generic ComboBox. If I declare a new class like this: public class GComboBox <Type> : ComboBox { // Some code } then GComboBox will not appear in the toolbox of Windows Form. How do I make it appear in the toolbox so that I can put it there as I would be able to put any other derived non-generic ComboBox? 回答1: the easiest way to use this GComboBox is this: use typical

C# databinding on combobox

。_饼干妹妹 提交于 2019-12-13 00:50:07
问题 I can't understand the following 2 issues given this code. I mapped a combobox to a custom object and I want each time that the selected value change on the combobox, the custom object changes too. public partial class MainForm : Form { private Person _person; public MainForm() { InitializeComponent(); _person = new Person(); //Populating the combox, we have this.comboBoxCities.DataSource = this.cityBindingSource; cityBindingSource.Add(new City("London")); cityBindingSource.Add(new City(