views:

123

answers:

1

I am attempting to show both a ListView and ListBox on a Windows Form (C#). The difficulty I am having is in having the first row for both the ListView and ListBox highlighted when the application opens. Could someone please steer me in the right direction so that the first row of both the ListView and ListBox are highlighted when the application opens?

+1  A: 

For ListBox:

listBox1.SelectedIndex = 0;

Add this line after you have filled your ListBox with items.

Mee
Mee, Thank you very much. You're suggestion worked well for ListBox; but doesn't seem to apply for ListView. Any suggestions?
Bill
Looks difficult to select an item in a ListView, but you can try this: http://msdn.microsoft.com/en-us/library/y4x56c0b(VS.85).aspx(didn't work for me though)
Mee
Mee,Thank you again. I think I may have found the solution - listView1.Items[0].Focused = true;Bill
Bill
listview1.SelectedIndicies.Add(0); or listview1.Items[0].Selected = true;
Grammarian