PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework Problem with ListView Selection First Time

Reply

Problem with ListView Selection First Time

 
Thread Tools Rate Thread
Old 01-08-2005, 07:08 PM   #1
Peter Kellner
Guest
 
Posts: n/a
Default Problem with ListView Selection First Time


When I create a very simple listview (as the only control in the
smartphone app) the down button the the pad doesn't move the cursor down
until the second press. After that it works fine. When I add keypress
and keydown events they all fire. I just don't understand why the
selected item stays put until I press it twice. (again, just on the
first time). Here is the simplest code I can think of that demonstrates
this problem.

private void Formtest_Load(object sender, EventArgs e)
{
ListViewItem lvi1 = new ListViewItem("listitem1");
ListViewItem lvi2 = new ListViewItem("listitem2");
ListViewItem lvi3 = new ListViewItem("listitem3");

listView1.Items.Add(lvi1);
listView1.Items.Add(lvi2);
listView1.Items.Add(lvi3);

listView1.Items[0].Selected = true;
}

Thanks for any help on this

--
Peter Kellner
http://peterkellner.net
  Reply With Quote
Old 01-08-2005, 07:26 PM   #2
Daniel Moth
Guest
 
Posts: n/a
Default Re: Problem with ListView Selection First Time

Try a listView1.Focus()

Cheers
Daniel
--
http://www.danielmoth.com/Blog/
"Peter Kellner" <peter@peterkellner.net> wrote in message
news:MPG.1d5804fd8830018b989694@news.sf.sbcglobal.net...
> When I create a very simple listview (as the only control in the
> smartphone app) the down button the the pad doesn't move the cursor down
> until the second press. After that it works fine. When I add keypress
> and keydown events they all fire. I just don't understand why the
> selected item stays put until I press it twice. (again, just on the
> first time). Here is the simplest code I can think of that demonstrates
> this problem.
>
> private void Formtest_Load(object sender, EventArgs e)
> {
> ListViewItem lvi1 = new ListViewItem("listitem1");
> ListViewItem lvi2 = new ListViewItem("listitem2");
> ListViewItem lvi3 = new ListViewItem("listitem3");
>
> listView1.Items.Add(lvi1);
> listView1.Items.Add(lvi2);
> listView1.Items.Add(lvi3);
>
> listView1.Items[0].Selected = true;
> }
>
> Thanks for any help on this
>
> --
> Peter Kellner
> http://peterkellner.net



  Reply With Quote
Old 01-08-2005, 10:36 PM   #3
Peter Kellner
Guest
 
Posts: n/a
Default Re: Problem with ListView Selection First Time

This followup was posted to
microsoft.public.dotnet.framework.compactframework

In article <e59nPaslFHA.708@TK2MSFTNGP09.phx.gbl>, dmoth74@hotmail.com
says...
> Try a listView1.Focus()
>
> Cheers
> Daniel
> --


Great hint. Almost worked. Made me think to try this:

listView1.Items[0].Focused = true;

which did work.

Thanks

--
Peter Kellner
http://peterkellner.net
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off