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
2010-06-05 20:39:29
Mee, Thank you very much. You're suggestion worked well for ListBox; but doesn't seem to apply for ListView. Any suggestions?
Bill
2010-06-05 20:46:36
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
2010-06-05 20:51:53
Mee,Thank you again. I think I may have found the solution - listView1.Items[0].Focused = true;Bill
Bill
2010-06-05 21:08:16
listview1.SelectedIndicies.Add(0); or listview1.Items[0].Selected = true;
Grammarian
2010-06-06 10:29:35