|
-
Jan 8th, 2007, 07:20 AM
#1
Thread Starter
Fanatic Member
FindByText & FindByValue
I know that using asp.net I can use "FindByText" and "FindByValue" to get find an item in a dropdown but is there no similar way to do this in a windows application.
Basically I have a string value and wish the dropdown to display the correct item to match the string.
-
Jan 8th, 2007, 07:58 AM
#2
Re: FindByText & FindByValue
Assuming you're using VB.Net you can use "IndexOf" to set the index of a given value by doing;
MyComboxBox.SelectedIndex = MyComboBox.Items.IndexOf("MyValueString")
I think you can also do;
MyComboBox.SelectedItem = "MyValueString"
Last edited by Bulldog; Jan 8th, 2007 at 08:02 AM.
-
Jan 8th, 2007, 09:03 AM
#3
Re: FindByText & FindByValue
The ComboBox doesn't have text and corresponding values unless it is bound to a data source. It has FindString and FindStringExact methods that llow you to find the index of an item by the text displayed for that item but there is no method to find an item by value. You can set the SelectedValue property directly, otherwise you'd have to find your desired item using methods of the data source.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|