Click here to Skip to main content
15,749,352 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a lisbox in my WinForm where items are filled from SQL database.
I want to select first item from listbox during the load in my WinForm.
How to do that?
Updated 1-Feb-11 1:46am

Add this code to form's load event
if (ListBox1.Items.Count > 0)
ListBox1.SelectedIndex = 0;
Share this answer
Set the SelectedIndex or SelectedItem property to 0
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900