By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

Setting SelectedValue in a list control

P: n/a
According to Microsoft's documentation, SelectedValue can be used to either
read or write to the SelectedValue property of a list control. I know I can
set it by binding the control to a datatable or array, but that seems like a
lot of work when I prefer to use a simple loop to add a small number of
items and values to a list control.

I've tried unsuccessfully to actually write to a control's SelectedValue
property. I suspect the problem is that I don't know how to specify the
index of the property.

Any ideas would be appreciated.

Thanks,
Steve Enzer
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
<< I've tried unsuccessfully to actually write to a control's SelectedValue
property. I suspect the problem is that I don't know how to specify the
index of the property. >>


You have to set the .SelectedItem property to a member of the .Items
collection. Here's an example:
List1.SelectedItem = List1.Items(2)

This selects the third item in the list (the index is zero-relative)

Karen Kenworthy
http://www.karenware.com/
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.