Click here to Skip to main content
16,020,622 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?
Posted
Updated 1-Feb-11 1:46am
v2

Add this code to form's load event
C#
if (ListBox1.Items.Count > 0)
{
ListBox1.SelectedIndex = 0;
}
 
Share this answer
 
v2
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