Solved

How to load a listbox with nothing selected

Posted on 2011-03-01
4
293 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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