Flutterby™!: dotNet Sucks

Next unread comment / Catchup all unread comments User Account Info | Logout | XML/Pilot/etc versions | Long version (with comments) | Weblog archives | Site Map | | Browse Topics

What

This is my first attempt at trying to build a Wiki-like knowledge base on top of the Flutterby content management system.

This is a place for explanation, description and static links on a topic that's either too broad to be covered under a single link, or that you're just too lazy to find the real link to.

Entries are automatically generated.

combo boxes and selected items when doing pulldowns

by:Dan Lyke started: 2003-04-16 22:44:23.25606+02 updated: 2003-07-18 22:48:27.959161+02

Warning: Geek alert! So, you've got a data structure with lots of items with a similar name:

public class PulldownItems {
public int num;
public PulldownItems(int pnum) { num = pnum;
public override string ToString() { return "A String"; }
}

And you populate it:

for (int i = 0; i < 20; i++) {
PulldownItems item = new PulldownItems(i);
this.comboBox1.Items.Add(item); }

And in the "Selected Index Changed" method you verify that you're getting the item you actually selected:

PulldownItems item = (PulldownItems)this.comboBox1.SelectedItem;
if (item != null)
this.textBox1.Text = item.num.ToString();

Then you can select an item down the list, verify in the text box that the item you selected is indeed the selected item, even arrow up and down in the list, but click on the pulldown and the highlighted item will be the first item of that name in the list.


Flutterby™ is a trademark claimed by

Dan Lyke
for the web publications at www.flutterby.com and www.flutterby.net.