473,545 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2750
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("pot ato").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.FindB yText("child"). Selected=true;

"John" <Jo**@discussio ns.microsoft.co m> wrote in message
news:11******** *************** ***********@mic rosoft.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******** ********@TK2MSF TNGP11.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("pot ato").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.FindB yText("child"). Selected=true;

"John" <Jo**@discussio ns.microsoft.co m> wrote in message
news:11******** *************** ***********@mic rosoft.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
22600
by: Peter Moscatt | last post by:
I am having trouble understanding the methods for the Listbox from Tk. If I was to select at item in the list using a mouse click (have already created the bind event) - what method returns the text of the selected item ? Pete
8
2824
by: Vipin Kedia | last post by:
Hi I have written a code for showing the list boxes as selected using a Listitem and the selected property of the items. Now I have 2 list boxes in my page. But it shows only the selected values of the last list box in both the list boxes. If i reverse the calls to the filllistbox methods it shows the value selected for the 1st list box in...
2
4576
by: Geir Baardsen | last post by:
Hi! From a listbox I'd like to send only selected items to a report. Items will include: OrderNr,Date,EmployeeNr from tblOrders ZipCode,City from tblZipCodes Name,Adr,ZipID from tblCustomers OrderNr,ItemID,Amount,Price,Discount from tblOrderDetails
2
19422
by: JP | last post by:
Hi, I am trying to loop through the listbox and read the selected items from the list, within a CLICK event on an aspx page. The following is what I have tried. It loops through the listbox, but none of the items' SELECTED property is TRUE while I have selected a few items. What am I missing? Dim strFunds As String
3
8452
by: Richard Albrecht | last post by:
I have been trying to figure out for days on how to read values from a Bound ListBox. The listBox gets the values from an Access Table. I can read values fine for Non-Bound ListBoxes, But the same code doesn't work for Bound, see below: Any one of these work for a non-bound listbox. Code:
2
2691
by: Srimadhi | last post by:
Displaying selected items at the top of the listbox Hi, I am having two listboxes - one with ids and second with the related names. When user selects an item in one listbox, the corresponding item will be selected in the second listbox too. The problem is, when the user selects an item and it is in the middle of the list, the user is not...
2
4073
by: Hitesh | last post by:
I have a listbox and the values get selected (highlighted) from code. I can highlight the corresponding list box items, but they do not show in the listbox I have to scroll through the list box to find them. How can I setFocus on the highlighted data items in the listbox after they are highlighted. The selection mode is set to multiple for...
3
19065
by: Mitch | last post by:
Is the following a correct representation of the relationship of the selected index to selected item: INDEX ITEM 0 "item 1" 1 "item 2" 2 "item 3" and so on. I keep getting the same string for selected index 0 and 1; i.e. both are "item 1". I'm new to C# and not exactly an accomplished programmer. Any suggestions?
4
6121
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the extra item just doesn't get added to the DropDownList: ============================================= <script runat="server"> Sub...
0
7499
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.