Selecting other listview item after removing one

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

    Selecting other listview item after removing one

    Hi,

    What's the best way to programmaticly select (click) another listview Item
    after removing the selected/focused one.

    using VB2005 Express.

    Thanks
    Bart


  • Dan Bass

    #2
    Re: Selecting other listview item after removing one


    Typically...
    - Get the index of the selected item and store in a local integer.
    - The remove the selected item
    - Now check to see that the selected item's index is less than the max index
    (list count -1). (I.E. did you just remove the last item in the menu)
    - If the index is still valid, select this item otherwise select the last
    item in the list.


    "Bart Steur" <solnews@xs4all .nlwrote in message
    news:eeXWTz0NIH A.5160@TK2MSFTN GP05.phx.gbl...
    Hi,
    >
    What's the best way to programmaticly select (click) another listview Item
    after removing the selected/focused one.
    >
    using VB2005 Express.
    >
    Thanks
    Bart
    >

    Comment

    • Bart Steur

      #3
      Re: Selecting other listview item after removing one

      Yes, got that, but how do I get it to trigger the click event?



      "Dan Bass" <danbass@REMOVE blueCAPSbottle. comwrote in message
      news:4366695A-088B-490C-B68E-BF13C3328A22@mi crosoft.com...
      >
      Typically...
      - Get the index of the selected item and store in a local integer.
      - The remove the selected item
      - Now check to see that the selected item's index is less than the max
      index (list count -1). (I.E. did you just remove the last item in the
      menu)
      - If the index is still valid, select this item otherwise select the last
      item in the list.
      >
      >
      "Bart Steur" <solnews@xs4all .nlwrote in message
      news:eeXWTz0NIH A.5160@TK2MSFTN GP05.phx.gbl...
      >Hi,
      >>
      >What's the best way to programmaticly select (click) another listview
      >Item after removing the selected/focused one.
      >>
      >using VB2005 Express.
      >>
      >Thanks
      >Bart
      >>
      >

      Comment

      • Dan Bass

        #4
        Re: Selecting other listview item after removing one

        I would do it on the "SelectedIndexC hanged" event.
        In Visual Studio, if you click on the list, then in the properties window,
        click on the little lightening bolt, this shows you what events you
        currently have configured. To create one, find the event and double click on
        it. This will create a new event in the code.

        Alternatively, to do it manually. In the constructor of the form, you can
        reference the list promatically (provided it's already been created) and
        find the event in there and specify a target event handler method to handle
        that event.

        Hope that helps.



        "Bart Steur" <solnews@xs4all .nlwrote in message
        news:eem4BRBOIH A.6108@TK2MSFTN GP03.phx.gbl...
        Yes, got that, but how do I get it to trigger the click event?
        >
        >
        >
        "Dan Bass" <danbass@REMOVE blueCAPSbottle. comwrote in message
        news:4366695A-088B-490C-B68E-BF13C3328A22@mi crosoft.com...
        >>
        >Typically...
        >- Get the index of the selected item and store in a local integer.
        >- The remove the selected item
        >- Now check to see that the selected item's index is less than the max
        >index (list count -1). (I.E. did you just remove the last item in the
        >menu)
        >- If the index is still valid, select this item otherwise select the last
        >item in the list.
        >>
        >>
        >"Bart Steur" <solnews@xs4all .nlwrote in message
        >news:eeXWTz0NI HA.5160@TK2MSFT NGP05.phx.gbl.. .
        >>Hi,
        >>>
        >>What's the best way to programmaticly select (click) another listview
        >>Item after removing the selected/focused one.
        >>>
        >>using VB2005 Express.
        >>>
        >>Thanks
        >>Bart
        >>>
        >>
        >
        >

        Comment

        • Bart Steur

          #5
          Re: Selecting other listview item after removing one

          I don't think I understand your solution.

          I'm used to VB6 (For almost a decade). There you had the ItemClick Event
          which supplied the Item that was clicked. Now online help suggests to use
          the Click event in combination with Listview.FocusI tem.
          So I used that. Clicking an Item loads an image into a picturebox.
          So to delete one I use Listview.Focuse dItem.Remove. Now after deleting I
          want to programmaticly click the preceding item in the list. So the
          Click_event coding is triggered and the image is shown.

          Thanks
          Bart


          "Dan Bass" <danbass@REMOVE blueCAPSbottle. comwrote in message
          news:7CF65E32-2D99-499C-A8D9-94B6782D4BC6@mi crosoft.com...
          >I would do it on the "SelectedIndexC hanged" event.
          In Visual Studio, if you click on the list, then in the properties window,
          click on the little lightening bolt, this shows you what events you
          currently have configured. To create one, find the event and double click
          on it. This will create a new event in the code.
          >
          Alternatively, to do it manually. In the constructor of the form, you can
          reference the list promatically (provided it's already been created) and
          find the event in there and specify a target event handler method to
          handle that event.
          >
          Hope that helps.
          >
          >
          >
          "Bart Steur" <solnews@xs4all .nlwrote in message
          news:eem4BRBOIH A.6108@TK2MSFTN GP03.phx.gbl...
          >Yes, got that, but how do I get it to trigger the click event?
          >>
          >>
          >>
          >"Dan Bass" <danbass@REMOVE blueCAPSbottle. comwrote in message
          >news:4366695 A-088B-490C-B68E-BF13C3328A22@mi crosoft.com...
          >>>
          >>Typically.. .
          >>- Get the index of the selected item and store in a local integer.
          >>- The remove the selected item
          >>- Now check to see that the selected item's index is less than the max
          >>index (list count -1). (I.E. did you just remove the last item in the
          >>menu)
          >>- If the index is still valid, select this item otherwise select the
          >>last item in the list.
          >>>
          >>>
          >>"Bart Steur" <solnews@xs4all .nlwrote in message
          >>news:eeXWTz0N IHA.5160@TK2MSF TNGP05.phx.gbl. ..
          >>>Hi,
          >>>>
          >>>What's the best way to programmaticly select (click) another listview
          >>>Item after removing the selected/focused one.
          >>>>
          >>>using VB2005 Express.
          >>>>
          >>>Thanks
          >>>Bart
          >>>>
          >>>
          >>
          >>
          >

          Comment

          • Dan Bass

            #6
            Re: Selecting other listview item after removing one

            Bart,

            You want to select an item and have it display the picture in the listview,
            which I believe you have at the moment?
            Now you want to remove this item (presumably with some delete button press)
            and have another item selected, and in doing so have the picture for that
            list item displayed?
            What version of Visual Studio are you using?

            If this is not what you are doing, please first describe this, then maybe
            we'll be able to help.

            Thanks.
            Daniel.

            "Bart Steur" <solnews@xs4all .nlwrote in message
            news:e9zTBRMOIH A.5224@TK2MSFTN GP02.phx.gbl...
            >I don't think I understand your solution.
            >
            I'm used to VB6 (For almost a decade). There you had the ItemClick Event
            which supplied the Item that was clicked. Now online help suggests to use
            the Click event in combination with Listview.FocusI tem.
            So I used that. Clicking an Item loads an image into a picturebox.
            So to delete one I use Listview.Focuse dItem.Remove. Now after deleting I
            want to programmaticly click the preceding item in the list. So the
            Click_event coding is triggered and the image is shown.
            >
            Thanks
            Bart
            >
            >
            "Dan Bass" <danbass@REMOVE blueCAPSbottle. comwrote in message
            news:7CF65E32-2D99-499C-A8D9-94B6782D4BC6@mi crosoft.com...
            >>I would do it on the "SelectedIndexC hanged" event.
            >In Visual Studio, if you click on the list, then in the properties
            >window, click on the little lightening bolt, this shows you what events
            >you currently have configured. To create one, find the event and double
            >click on it. This will create a new event in the code.
            >>
            >Alternativel y, to do it manually. In the constructor of the form, you can
            >reference the list promatically (provided it's already been created) and
            >find the event in there and specify a target event handler method to
            >handle that event.
            >>
            >Hope that helps.
            >>
            >>
            >>
            >"Bart Steur" <solnews@xs4all .nlwrote in message
            >news:eem4BRBOI HA.6108@TK2MSFT NGP03.phx.gbl.. .
            >>Yes, got that, but how do I get it to trigger the click event?
            >>>
            >>>
            >>>
            >>"Dan Bass" <danbass@REMOVE blueCAPSbottle. comwrote in message
            >>news:436669 5A-088B-490C-B68E-BF13C3328A22@mi crosoft.com...
            >>>>
            >>>Typically. ..
            >>>- Get the index of the selected item and store in a local integer.
            >>>- The remove the selected item
            >>>- Now check to see that the selected item's index is less than the max
            >>>index (list count -1). (I.E. did you just remove the last item in the
            >>>menu)
            >>>- If the index is still valid, select this item otherwise select the
            >>>last item in the list.
            >>>>
            >>>>
            >>>"Bart Steur" <solnews@xs4all .nlwrote in message
            >>>news:eeXWTz0 NIHA.5160@TK2MS FTNGP05.phx.gbl ...
            >>>>Hi,
            >>>>>
            >>>>What's the best way to programmaticly select (click) another listview
            >>>>Item after removing the selected/focused one.
            >>>>>
            >>>>using VB2005 Express.
            >>>>>
            >>>>Thanks
            >>>>Bart
            >>>>>
            >>>>
            >>>
            >>>
            >>
            >
            >

            Comment

            Working...