ComboBox

S

Soulless

Hi,

I have a scenario where I have a populated combobox from an enumerated
datatype (DbProvider). I then save the text value chosen to XML.

When the app is opened up, I would like to read the value from XML,
which is no problem and have the combobox check for the value and
display that value. If the enumerated datatype does not appear inthe
list, however, I do not want it to do anything.

Do that make sense? Basically, how can i set my combobox to a value
but only if it exists in the combo as a valid value?

Thanks!
 
N

Nicholas Paldino [.NET/C# MVP]

Soulless,

Are you adding the items through the Items property on the ComboBox
(assuming this is a Windows Forms app)? If so, then just call IndexOf on
the ObjectCollection property returned by the call to the Items property on
the ComboBox.

If you are data binding the list, then you should be able to call
IndexOf on the data source (since it implements IList).
 
S

Soulless

Soulless,

Are you adding the items through the Items property on the ComboBox
(assuming this is a Windows Forms app)? If so, then just call IndexOf on
the ObjectCollection property returned by the call to the Items property on
the ComboBox.

If you are data binding the list, then you should be able to call
IndexOf on the data source (since it implements IList).

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




I have a scenario where I have a populated combobox from an enumerated
datatype (DbProvider). I then save the text value chosen to XML.
When the app is opened up, I would like to read the value from XML,
which is no problem and have the combobox check for the value and
display that value. If the enumerated datatype does not appear inthe
list, however, I do not want it to do anything.
Do that make sense? Basically, how can i set my combobox to a value
but only if it exists in the combo as a valid value?
Thanks!- Hide quoted text -

- Show quoted text -

Thanks! i'm going to look into that!

right now to populate I just set the datasource of the combo box equal
to the enum dbprovider values.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top