View selected item in listView

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

    View selected item in listView

    I select an item in a listView by code and it works fine (thanks to Morten
    Wennevik who tell me how to do it) but if the item is out of screen (there
    are a lot of items) I'd like to see it selected. Actually, the item is
    selected but I can't see because is out of screen.

    Thank you.


  • ShaneB

    #2
    Re: View selected item in listView

    Take a look at the ListView.Ensure Visible method.

    ShaneB


    "Alberto" <alberto@nospam .com> wrote in message
    news:ufkCBqyzEH A.2568@TK2MSFTN GP10.phx.gbl...[color=blue]
    >I select an item in a listView by code and it works fine (thanks to Morten
    >Wennevik who tell me how to do it) but if the item is out of screen (there
    >are a lot of items) I'd like to see it selected. Actually, the item is
    >selected but I can't see because is out of screen.
    >
    > Thank you.
    >[/color]


    Comment

    • Morten Wennevik

      #3
      Re: View selected item in listView

      Hi Alberto,

      Add EnsureVisible(l st.FocusedItem. Index); to each key in the switch.

      ....
      lst.EnsureVisib le(lst.FocusedI tem.Index);
      e.Handled = true;
      break;
      ....

      --
      Happy Coding!
      Morten Wennevik [C# MVP]

      Comment

      Working...