ListBox Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a relatively simple question. I created a blank project, and put a
listbox on the form. Then in the "Form1_Load" function I added one line of
code.

listBox1.Items.Add("Scott");

When I compile and run the program it runs, but the listbox appears to have
an item (I can highlight the first row), but nothing is displayed in the
listbox. What am I doing wrong? Thanks

Scott
 
I think you need to set the SelectedIndex property of the control to zero.
It defaults to -1, which means no selection. See 'ListBox.SelectedIndex
Property' in Help for more information.
 
I tried that and it highlights the first row in the listbox although there is
still nothing displayed. If I add more code to add more rows to the listbox,
each row I add still displays an empty line in the listbox, although I can
select any row.
 
Back
Top