473,326 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

specifying selected item in a listbox

Hello again :

How do I specify which item in a listbox I want selected
The listbox is already populated, and if the user types in a value into a textbox, I want that value to be highlighted in the listbox

Thanks
Ambe

Nov 20 '05 #1
3 1397
* "=?Utf-8?B?YW1iZXI=?=" <an*******@discussions.microsoft.com> scripsit:
How do I specify which item in a listbox I want selected?
The listbox is already populated, and if the user types in a value into a textbox, I want that value to be highlighted in the listbox.


Set the listbox's 'SelectedIndex' or 'SelectedItem' property.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
Nov 20 '05 #2
Yes, I figured that, but I'm looking for specific syntax to force a listbox.selecteditem to equal a texbox
Thanks
Ambe

Nov 20 '05 #3
Amber,

* "=?Utf-8?B?QW1iZXI=?=" <an*******@discussions.microsoft.com> scripsit:
Yes, I figured that, but I'm looking for specific syntax to force a listbox.selecteditem to equal a texbox.


\\\
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim i As Integer = Me.ListBox1.FindString(Me.TextBox1.Text)
If i = ListBox.NoMatches Then
Me.ListBox1.SelectedIndex = -1
Else
Me.ListBox1.SelectedIndex = i
End If
End Sub
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
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...
4
by: Filips Benoit | last post by:
Dear All, I have code that selects - find and select - 1 item in a large listbox. This works Ok but most of the time the selected item isn't visible without scrolling down manualy. Is this...
6
by: David De Cotis | last post by:
Hello all, I am trying to go through a ListBox and verify if am item was selected. If an item was selected, I would like to get a handle of the item and simply do a response.write on the selected...
1
by: Karen Grube | last post by:
Hi! I'm using a standard server side ASP.Net listbox control on a web form. The page is basically various shades of green. The listbox itself has a pale green background and forest green text...
2
by: John | last post by:
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....
2
by: Greg | last post by:
I have a listbox inside of a DetailsView. There are three departments to choose from, Corporate, Group, Vacation. The listbox is set to SelectionMode="multiple". I think I have this loop setup...
3
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...
4
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...
3
by: peter.mosley | last post by:
I've tried googling for the answer to this problem, without any luck. I'm sure the truth must be out there somewhere! I have a multiselect listbox populated with many items (set by the RowSource...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.