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
Tim Wilson - 30 Mar 2004 06:03 GMT
Are you trying to do multi-selection or just single-selection? I have tried
code similar to the code you posted and I do not see an issue. You might
need to post more of a complete picture as to what you are trying to do. In
addition, I don't specifically remember and issue like this but if you are
not already you may consider moving to CF SP2 to see if that helps at all.
http://www.microsoft.com/downloads/details.aspx?FamilyID=10600643-09b3-46d8-ba28
-bc494bc20d26&DisplayLang=en

Signature
Tim Wilson
.Net Compact Framework MVP
{cf147fdf-893d-4a88-b258-22f68a3dbc6a}
> Hi -
>
[quoted text clipped - 28 lines]
>
> - Jeff
Jeff - 31 Mar 2004 18:35 GMT
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
> Are you trying to do multi-selection or just single-selection? I have tried
> code similar to the code you posted and I do not see an issue. You might
[quoted text clipped - 35 lines]
> >
> > - Jeff