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

selected items at the top of the listbox

P: n/a
I have a listbox that is databound when my form loads. A user
can then select and option using a drop down box. When the user
selects an option the corresponding items in the listbox gets selected.
How can I show those selected items at the top of my listbox. The
issue is when the user selects an item and it is in the middle of the list,
the user is not able to know an item it is selected or not unless they scroll
through the listbox.

Mar 14 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

what I undesrstand ... is that you have some values in database... from
those values ListBox/dropdown is populated... User select some item and it
is saved in database.
when next time page is loaded and dropdown is populated you want to show the
item on top that user selected last time...

you can use the following scenario
First get the value from database that user selected last time let say that
item is "potato"

then dropdown.items.findByText("potato").selected=true;

this statement will make it selected

in above case you might get error that dropdown cannot have multiple indexes
selected

then you can try this
for(int i=0;i<ddl.Items.Count;i++)

{

ddl.Items[i].Selected=false;

}

ddl.Items.FindByText("child").Selected=true;

"John" <Jo**@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
I have a listbox that is databound when my form loads. A user
can then select and option using a drop down box. When the user
selects an option the corresponding items in the listbox gets selected.
How can I show those selected items at the top of my listbox. The
issue is when the user selects an item and it is in the middle of the
list,
the user is not able to know an item it is selected or not unless they
scroll
through the listbox.

Mar 16 '06 #2

P: n/a
I can get it to select that items, but how do I get them to the top or
scroll to the selected items. That's were I'm stuck.
"Munawar Hussain" <mu*******@msn.com> wrote in message
news:Oa****************@TK2MSFTNGP11.phx.gbl...
Hi,

what I undesrstand ... is that you have some values in database... from
those values ListBox/dropdown is populated... User select some item and it
is saved in database.
when next time page is loaded and dropdown is populated you want to show
the item on top that user selected last time...

you can use the following scenario
First get the value from database that user selected last time let say
that item is "potato"

then dropdown.items.findByText("potato").selected=true;

this statement will make it selected

in above case you might get error that dropdown cannot have multiple
indexes selected

then you can try this
for(int i=0;i<ddl.Items.Count;i++)

{

ddl.Items[i].Selected=false;

}

ddl.Items.FindByText("child").Selected=true;

"John" <Jo**@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
I have a listbox that is databound when my form loads. A user
can then select and option using a drop down box. When the user
selects an option the corresponding items in the listbox gets selected.
How can I show those selected items at the top of my listbox. The
issue is when the user selects an item and it is in the middle of the
list,
the user is not able to know an item it is selected or not unless they
scroll
through the listbox.


Mar 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.