Listview, change index programically

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

    #1

    Listview, change index programically

    Dear all,

    I have a list view, i dont like this list view very much
    anymore as it hasn't been the easiest object to use thus
    far.
    Now i like it even less.
    I have a problem with it, I wish to change the selected
    index (i set selected to 1 so it can only select one) but
    it keeps telling me it is read only.
    Surely there must be a way round this!?!?

    If anyone knows please tell me or give me a clue :)
    Thanks for any help given.

    jax
  • Dmitriy Lapshin [C# / .NET MVP]

    #2
    Re: Listview, change index programically

    Hi Jax,

    There's also SelectedIndexes collection on the ListView. I am not sure it
    can be modified but you might also want to check out this one.

    --
    Dmitriy Lapshin [C# / .NET MVP]
    X-Unity Test Studio

    Bring the power of unit testing to VS .NET IDE

    "Jax" <anonymous@disc ussions.microso ft.com> wrote in message
    news:cf2801c3ba 80$f7c4b5b0$a60 1280a@phx.gbl.. .[color=blue]
    > Dear all,
    >
    > I have a list view, i dont like this list view very much
    > anymore as it hasn't been the easiest object to use thus
    > far.
    > Now i like it even less.
    > I have a problem with it, I wish to change the selected
    > index (i set selected to 1 so it can only select one) but
    > it keeps telling me it is read only.
    > Surely there must be a way round this!?!?
    >
    > If anyone knows please tell me or give me a clue :)
    > Thanks for any help given.
    >
    > jax[/color]

    Comment

    • Guest's Avatar

      #3
      Re: Listview, change index programically

      Nope it's read only as well, I already tried. :(
      Anyone else got any ideas?

      jax[color=blue]
      >-----Original Message-----
      >Hi Jax,
      >
      >There's also SelectedIndexes collection on the ListView.[/color]
      I am not sure it[color=blue]
      >can be modified but you might also want to check out this[/color]
      one.[color=blue]
      >
      >--
      >Dmitriy Lapshin [C# / .NET MVP]
      >X-Unity Test Studio
      >http://x-unity.miik.com.ua/teststudio.aspx
      >Bring the power of unit testing to VS .NET IDE
      >
      >"Jax" <anonymous@disc ussions.microso ft.com> wrote in[/color]
      message[color=blue]
      >news:cf2801c3b a80$f7c4b5b0$a6 01280a@phx.gbl. ..[color=green]
      >> Dear all,
      >>
      >> I have a list view, i dont like this list view very much
      >> anymore as it hasn't been the easiest object to use thus
      >> far.
      >> Now i like it even less.
      >> I have a problem with it, I wish to change the selected
      >> index (i set selected to 1 so it can only select one)[/color][/color]
      but[color=blue][color=green]
      >> it keeps telling me it is read only.
      >> Surely there must be a way round this!?!?
      >>
      >> If anyone knows please tell me or give me a clue :)
      >> Thanks for any help given.
      >>
      >> jax[/color]
      >
      >.
      >[/color]

      Comment

      • ToddT

        #4
        Re: Listview, change index programically

        myListView.Item s(someIndex).Se lected = True


        On Thu, 4 Dec 2003 08:09:17 -0800, "Jax"
        <anonymous@disc ussions.microso ft.com> wrote:
        [color=blue]
        >Dear all,
        >
        >I have a list view, i dont like this list view very much
        >anymore as it hasn't been the easiest object to use thus
        >far.
        >Now i like it even less.
        >I have a problem with it, I wish to change the selected
        >index (i set selected to 1 so it can only select one) but
        >it keeps telling me it is read only.
        >Surely there must be a way round this!?!?
        >
        >If anyone knows please tell me or give me a clue :)
        >Thanks for any help given.
        >
        >jax[/color]

        Comment

        • Ignacio Machin \( .NET/ C#  MVP \)

          #5
          Re: Listview, change index programically

          Hi,

          You have to set to true the ListViewItem.Se lected property:

          ListView.Items[ index ].Selected = true;

          Cheers,

          --
          Ignacio Machin,
          ignacio.machin AT dot.state.fl.us
          Florida Department Of Transportation

          "Jax" <anonymous@disc ussions.microso ft.com> wrote in message
          news:cf2801c3ba 80$f7c4b5b0$a60 1280a@phx.gbl.. .[color=blue]
          > Dear all,
          >
          > I have a list view, i dont like this list view very much
          > anymore as it hasn't been the easiest object to use thus
          > far.
          > Now i like it even less.
          > I have a problem with it, I wish to change the selected
          > index (i set selected to 1 so it can only select one) but
          > it keeps telling me it is read only.
          > Surely there must be a way round this!?!?
          >
          > If anyone knows please tell me or give me a clue :)
          > Thanks for any help given.
          >
          > jax[/color]


          Comment

          • Jax

            #6
            Listview, change index programically

            Thanks Todd and Ignacio!

            Thats great and works fine!
            Many more thanks
            and some more
            and another

            :)
            jax
            [color=blue]
            >-----Original Message-----
            >Dear all,
            >
            >I have a list view, i dont like this list view very much
            >anymore as it hasn't been the easiest object to use thus
            >far.
            >Now i like it even less.
            >I have a problem with it, I wish to change the selected
            >index (i set selected to 1 so it can only select one) but
            >it keeps telling me it is read only.
            >Surely there must be a way round this!?!?
            >
            >If anyone knows please tell me or give me a clue :)
            >Thanks for any help given.
            >
            >jax
            >.
            >[/color]

            Comment

            Working...