471,578 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,578 software developers and data experts.

selected items at the top of the listbox

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
2 2609
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
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.

Similar topics

4 posts views Thread by Peter Moscatt | last post: by
8 posts views Thread by Vipin Kedia | last post: by
2 posts views Thread by Hitesh | last post: by
3 posts views Thread by Mitch | last post: by
4 posts views Thread by rn5a | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.