flynn Posted April 24, 2006 Posted April 24, 2006 I am wanting to add an item to a combobox, so I thought I could do something like this: dim cboItem as ComboBoxItem cboItem = ComboBox1.add() cboItem.text = "123" cboItem.tag = "abc" Is there a way to create a combobox item, then set the values of that item? tia, flynn Quote
Cags Posted April 24, 2006 Posted April 24, 2006 Create a class something like this... public class ComboBoxItem { private string _displayMember; private int _value; public ComboBoxItem(string text, int val) { _displayMember = text; _value = val; } public string DisplayMember { get { return _displayMember; } set { _displayMember = value; } } public int Value { get { return _value; } set { _value = value; } } } Then use it something like... ComboBox comboBox1 = new ComboBox(); ComboBoxItem newItem1 = new ComboBoxItem("hello", 10); ComboBoxItem newItem2 = new ComboBoxItem("Bob", 9); comboBox1.DisplayMember = "DisplayMember"; comboBox1.ValueMember = "Value"; comboBox1.Items.Add(newItem1); comboBox1.Items.Add(newItem2); Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.