Log in

View Full Version : PPC2003 vb.net


pdanford
02-23-2005, 02:37 PM
I am trying to programitcally build combo boxes onto a form.

I can successfully build the control and add items into the combo boxes.

However, when built, it seems that only the .SelectedIndex and .SelectedItem properties have values. I would also like to store some information in the .SelectedValue property.

I can see no way of specifying this when adding items into my combo box

ie. using objCombo.Items.Add("paul") before calling Controls.Add(objCombo)

Am I missing something obvious?

Any help appreciated!

Thanks,
pdanford

Wiggster
02-23-2005, 02:42 PM
If you want to add a value to the form, you need to add an object with that value.

I'm at work right now, and only have Visual Studio at home, but I'll try and give you a little direction: make your own struct or class, with a text field and whatever other values you want. Then make a ToString function, which returns the string member of the class. Then, whenever you're adding something, add a new object using your custom class. If I'm not mistaken, it'll use the ToString() property from the object to display the text, and you can access the selected item to get any public properties, functions, or variables therein.

Sorry for being vague, I'll try and have a working example tonight.