Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selection of first item in ListView on Load

Status
Not open for further replies.

mHos

Programmer
Mar 3, 2003
19
US
I am having trouble with the listView in VB.NET. This seemed to be working the other day, and now it isn't. Now I get an error -> it tells my that my index is out of bounds of the collection or array size (or something like that).

DETAILS:
I have a listview in report mode. I have added my column headers and all of my items. Then I want it to select my first item, and I call the lv_Click() function.

In the lv_Click function I do certain things based on the index of the selected item.

PROBLEM:
in the load function, i do
lv.items(0).select = true
lv_Click(sender, new system.eventArgs())


when I check out the lv.selectedItems.count , it is =0. Everything that I have found says that when you do
lv.items(0).select = true, that it should select it, but it isn't being put into the lv.selecteditems collection. How do I make it do it?
 
I figured it out. I move those two calls to a pre-Load function, and that is why it was having problems.

I found that if I did everything else in a pre-load function, and then just did those two calls in the load function, that it worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top