Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. get the value of the selecteditem in a list view

get the value of the selecteditem in a list view

Scheduled Pinned Locked Moved C#
tutorialquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prasadbuddhika
    wrote on last edited by
    #1

    how to get a specified column value from the list view. listview row contains (x,y,z) and i want to get only the y ?

    B 1 Reply Last reply
    0
    • P prasadbuddhika

      how to get a specified column value from the list view. listview row contains (x,y,z) and i want to get only the y ?

      B Offline
      B Offline
      bcozican
      wrote on last edited by
      #2

      Hi prasadbuddhika, Try listview.items[rowIndex].subitems[IndexOfColum] items[rowIndex] returns the first column and subitems[0] is the second column etc... Hope this helps...

      L 1 Reply Last reply
      0
      • B bcozican

        Hi prasadbuddhika, Try listview.items[rowIndex].subitems[IndexOfColum] items[rowIndex] returns the first column and subitems[0] is the second column etc... Hope this helps...

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        bcozican wrote:

        subitems[0] is the second column

        IIRC, it is the first.

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 beta 1 - out now!
        ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

        B 1 Reply Last reply
        0
        • L leppie

          bcozican wrote:

          subitems[0] is the second column

          IIRC, it is the first.

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 beta 1 - out now!
          ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

          B Offline
          B Offline
          bcozican
          wrote on last edited by
          #4

          :~ listview.items[0].subitems[0] refers to the second column in the listview. listview.items[0] refers to the first column. Or am i missing something..?

          L 2 Replies Last reply
          0
          • B bcozican

            :~ listview.items[0].subitems[0] refers to the second column in the listview. listview.items[0] refers to the first column. Or am i missing something..?

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            bcozican wrote:

            Or am i missing something..?

            A unit test perhaps! I just double checked, SubItems[0] returns the 1st column. :)

            xacc.ide - now with TabsToSpaces support
            IronScheme - 1.0 beta 1 - out now!
            ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

            1 Reply Last reply
            0
            • B bcozican

              :~ listview.items[0].subitems[0] refers to the second column in the listview. listview.items[0] refers to the first column. Or am i missing something..?

              L Offline
              L Offline
              leppie
              wrote on last edited by
              #6

              From MSDN: The first subitem in the ListViewItem..::.ListViewSubItemCollection is always the item that owns the subitems. When performing operations on subitems in the collection, be sure to reference index position 1 instead of 0 to make changes to the first subitem.

              xacc.ide - now with TabsToSpaces support
              IronScheme - 1.0 beta 1 - out now!
              ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

              B 1 Reply Last reply
              0
              • L leppie

                From MSDN: The first subitem in the ListViewItem..::.ListViewSubItemCollection is always the item that owns the subitems. When performing operations on subitems in the collection, be sure to reference index position 1 instead of 0 to make changes to the first subitem.

                xacc.ide - now with TabsToSpaces support
                IronScheme - 1.0 beta 1 - out now!
                ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

                B Offline
                B Offline
                bcozican
                wrote on last edited by
                #7

                Sorry my bad ;P

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups