Solved

How to load a listbox with nothing selected

Posted on 2011-03-01
4
294 Views
Last Modified: 2012-05-11
How can I load a listbox and not have the first line highlighted/selected.  Thanks
0
Comment
Question by:running32
4 Comments
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 35011268
Change the focus of the form to a different control. So set it to

button.Focus();

Open in new window


I believe the listbox won't show selection if it is not selected. You can even set focus to the form or page.
0
 

Author Comment

by:running32
ID: 35011350
No that doesn't seem to work
0
 
LVL 8

Accepted Solution

by:
PagodNaUtak earned 500 total points
ID: 35013765
After loading the items in the listbox execute this line of code:
listbox1.selectedindex = -1

Open in new window

0
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 35018496
Another alternative can be:

Control SelectionMode property of ListBox.

Private Sub Form2_Load(sender As Object, e As EventArgs)
	listBox1.SelectionMode = SelectionMode.None
End Sub

Private Sub listBox1_MouseClick(sender As Object, e As MouseEventArgs)
	listBox1.SelectionMode = SelectionMode.One
End Sub

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert to Hour/minute textbox and compare 3 52
Spacing between controls 4 30
Iterate a dictionnary to change values 4 53
SQL syntax in VB.net 5 29
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now