Selecting Listview Rows

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi -

I'm having a problem programmatically selecting listview items.

I have a listview (Details view) with 59 rows, showing 7 visible rows.
My first selection runs fine, but my second selection throws a native
exception. For example, the following 4 statements run fine:

frmlist.lvwList.Items(9).Focused=True
frmlist.lvwList.Items(9).Selected=True
frmlist.lvwList.EnsureVisible(9)
frmlist.lvwList.Refresh

But if I try to repeat the process, I get the exception on the
selected statement:

frmlist.lvwList.Items(25).Focused=True
frmlist.lvwList.Items(25).Selected=True

The error (displayed on the emulator screen) is:

"A Native exception has occurred in MyApp.exe. Select Quit and then
restart this program, or select Details for more information."

(If I select the Details button, nothing happens.) Quit terminates
the session.

What am I doing wrong??

Thanks for your help.

- Jeff
 
Thanks Tim -

I think I've resolved the problem. I had been using the
SelectedIndexChanged event to trigger my code, and I should have been
using ItemActivate.

- Jeff
 
Back
Top