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. ListView Fundamentals :: C#

ListView Fundamentals :: C#

Scheduled Pinned Locked Moved C#
csharptutorialquestion
16 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.
  • V valikac

    Nice!!! Thanks. One last question on this item. How do you determine exactly what item the user selects via mouse? For example, let say I click on item 2, I want the program to do something with item 2. Kuphryn

    D Offline
    D Offline
    David Stone
    wrote on last edited by
    #4

    Then you would use the myListView.SelectedItems or myListView.SelectedIndices property instead of myListView.Items By the way, there are some really cool replacements for the standard list view. Consider this one for your app instead. Carlos really does a good job on custom controls. He also explains what's wrong with the standard one and why he implemented the new features that he did. http://www.codeproject.com/cs/miscctrl/sortedlistview.asp[^]


    I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

    V 1 Reply Last reply
    0
    • D David Stone

      Then you would use the myListView.SelectedItems or myListView.SelectedIndices property instead of myListView.Items By the way, there are some really cool replacements for the standard list view. Consider this one for your app instead. Carlos really does a good job on custom controls. He also explains what's wrong with the standard one and why he implemented the new features that he did. http://www.codeproject.com/cs/miscctrl/sortedlistview.asp[^]


      I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #5

      Okay. Thanks. I tried using SelectedItems, but it does not return the correct selected item. For example, it always return index 0 even if I select index 10. Kuphryn

      D 1 Reply Last reply
      0
      • V valikac

        Okay. Thanks. I tried using SelectedItems, but it does not return the correct selected item. For example, it always return index 0 even if I select index 10. Kuphryn

        D Offline
        D Offline
        David Stone
        wrote on last edited by
        #6

        Are you handling the SelectedIndexChanged event? And, since SelectedItems is a collection, did you access it like this: myListView.SelectedItems[0]


        I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

        V 1 Reply Last reply
        0
        • D David Stone

          Are you handling the SelectedIndexChanged event? And, since SelectedItems is a collection, did you access it like this: myListView.SelectedItems[0]


          I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

          V Offline
          V Offline
          valikac
          wrote on last edited by
          #7

          Yes. I added a handler for SelectedIndexChanged event and checked SelectedItems[...]. However, for some reason item 0 is always selected even if I click on item 2002. Weird! Kuphryn

          D 1 Reply Last reply
          0
          • V valikac

            Yes. I added a handler for SelectedIndexChanged event and checked SelectedItems[...]. However, for some reason item 0 is always selected even if I click on item 2002. Weird! Kuphryn

            D Offline
            D Offline
            David Stone
            wrote on last edited by
            #8

            Actually, I just played around with it a bit, and you should handle the click event instead. Then do myListView.SelectedItems[0]. Oh, and you have to use 0 because that's the only item in the collection of selected items.


            I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

            V 1 Reply Last reply
            0
            • D David Stone

              Actually, I just played around with it a bit, and you should handle the click event instead. Then do myListView.SelectedItems[0]. Oh, and you have to use 0 because that's the only item in the collection of selected items.


              I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

              V Offline
              V Offline
              valikac
              wrote on last edited by
              #9

              Nice! Your solution works perfect! Thanks again, Kuphryn

              D 1 Reply Last reply
              0
              • V valikac

                Nice! Your solution works perfect! Thanks again, Kuphryn

                D Offline
                D Offline
                David Stone
                wrote on last edited by
                #10

                kuphryn wrote: Your solution works perfect! Cool! :cool: Glad I could help. Mind if I ask what your app does?


                I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

                V 1 Reply Last reply
                0
                • D David Stone

                  kuphryn wrote: Your solution works perfect! Cool! :cool: Glad I could help. Mind if I ask what your app does?


                  I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder

                  V Offline
                  V Offline
                  valikac
                  wrote on last edited by
                  #11

                  It is not an application. It is something I have to do for a school project. Thus, I do not consider it an application. Lets just say it is a "Hello World" instruction using C#. Thanks again, Kuphryn

                  D 1 Reply Last reply
                  0
                  • V valikac

                    It is not an application. It is something I have to do for a school project. Thus, I do not consider it an application. Lets just say it is a "Hello World" instruction using C#. Thanks again, Kuphryn

                    D Offline
                    D Offline
                    David Stone
                    wrote on last edited by
                    #12

                    Cool. Where do you go to school?


                    I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder Microsoft has reinvented the wheel, this time they made it round. -Peterchen on VS.NET

                    V 1 Reply Last reply
                    0
                    • D David Stone

                      Cool. Where do you go to school?


                      I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder Microsoft has reinvented the wheel, this time they made it round. -Peterchen on VS.NET

                      V Offline
                      V Offline
                      valikac
                      wrote on last edited by
                      #13

                      I go to school in, lets just say, a school to a pretty bad Computer Science program. Oh, I guess you already see that via the fact that we even consider C#. Kuphryn

                      D B 2 Replies Last reply
                      0
                      • V valikac

                        I go to school in, lets just say, a school to a pretty bad Computer Science program. Oh, I guess you already see that via the fact that we even consider C#. Kuphryn

                        D Offline
                        D Offline
                        David Stone
                        wrote on last edited by
                        #14

                        kuphryn wrote: Oh, I guess you already see that via the fact that we even consider C#. :wtf:What!?!?! That's a good school, IMO. Most schools won't even consider using these "bleeding edge" technologies. Are you in high school or college?


                        I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past. -Chris Maunder Microsoft has reinvented the wheel, this time they made it round. -Peterchen on VS.NET

                        1 Reply Last reply
                        0
                        • V valikac

                          I go to school in, lets just say, a school to a pretty bad Computer Science program. Oh, I guess you already see that via the fact that we even consider C#. Kuphryn

                          B Offline
                          B Offline
                          BarryJ
                          wrote on last edited by
                          #15

                          I'd LOVE it if my college had C# instead of Java!

                          V 1 Reply Last reply
                          0
                          • B BarryJ

                            I'd LOVE it if my college had C# instead of Java!

                            V Offline
                            V Offline
                            valikac
                            wrote on last edited by
                            #16

                            hahahah C# is a joke compared to C/C++. Kuphryn

                            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