?
Solved

How to load a listbox with nothing selected

Posted on 2011-03-01
4
Medium Priority
?
307 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

765 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