Programmatically selecting a listview item..??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vince

    #1

    Programmatically selecting a listview item..??

    I need to programmaticall y select the first item in a
    listview before the listview is displayed, so far I'm not
    having any luck. Here's what I tried in the init for the
    listview...

    LoadListView();
    listView4.Items[0].Selected = true;

    Also tried to invalidate and get a redraw, didn't make a
    difference...

    Thanks for any help.

    Vince
  • Norm Yuan

    #2
    Re: Programmaticall y selecting a listview item..??

    If you code is correct, I am sure it IS selected. But to visibly show the
    selection, the listview must have focus ( add listView4.Focus () following
    listView4.Items[0].Selected=true) , or ListView.HideSe lection property is set
    to false (default value is true).

    "vince" <vlusardi@sdcer a.org> wrote in message
    news:031201c344 c8$fddca670$a50 1280a@phx.gbl.. .[color=blue]
    > I need to programmaticall y select the first item in a
    > listview before the listview is displayed, so far I'm not
    > having any luck. Here's what I tried in the init for the
    > listview...
    >
    > LoadListView();
    > listView4.Items[0].Selected = true;
    >
    > Also tried to invalidate and get a redraw, didn't make a
    > difference...
    >
    > Thanks for any help.
    >
    > Vince[/color]


    Comment

    • Wesjackson

      #3
      Re: Programmaticall y selecting a listview item..??

      Try listview4.selec tedindex = 0

      its something along those lines.

      "vince" <vlusardi@sdcer a.org> wrote in message
      news:031201c344 c8$fddca670$a50 1280a@phx.gbl.. .[color=blue]
      > I need to programmaticall y select the first item in a
      > listview before the listview is displayed, so far I'm not
      > having any luck. Here's what I tried in the init for the
      > listview...
      >
      > LoadListView();
      > listView4.Items[0].Selected = true;
      >
      > Also tried to invalidate and get a redraw, didn't make a
      > difference...
      >
      > Thanks for any help.
      >
      > Vince[/color]


      Comment

      • vince

        #4
        Re: Programmaticall y selecting a listview item..??

        thanks, that was it, needed to set focus in addition to
        selecting...

        [color=blue]
        >-----Original Message-----
        >If you code is correct, I am sure it IS selected. But to[/color]
        visibly show the[color=blue]
        >selection, the listview must have focus ( add[/color]
        listView4.Focus () following[color=blue]
        >listView4.Item s[0].Selected=true) , or[/color]
        ListView.HideSe lection property is set[color=blue]
        >to false (default value is true).
        >
        >"vince" <vlusardi@sdcer a.org> wrote in message
        >news:031201c34 4c8$fddca670$a5 01280a@phx.gbl. ..[color=green]
        >> I need to programmaticall y select the first item in a
        >> listview before the listview is displayed, so far I'm[/color][/color]
        not[color=blue][color=green]
        >> having any luck. Here's what I tried in the init for[/color][/color]
        the[color=blue][color=green]
        >> listview...
        >>
        >> LoadListView();
        >> listView4.Items[0].Selected = true;
        >>
        >> Also tried to invalidate and get a redraw, didn't make[/color][/color]
        a[color=blue][color=green]
        >> difference...
        >>
        >> Thanks for any help.
        >>
        >> Vince[/color]
        >
        >
        >.
        >[/color]

        Comment

        Working...