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. Visual Basic
  4. DGV with duplicate rows

DGV with duplicate rows

Scheduled Pinned Locked Moved Visual Basic
databasequestion
8 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.
  • C Offline
    C Offline
    cstrader232
    wrote on last edited by
    #1

    I need to populate a DGV. I need to be able to index the rows of the DGV by a string variable. But I also need to have duplicate rows in the DGV. A collection allows me to index the rows the way I need to, but doesn't allow duplicate keys. Is there any other alternative? Thanks

    L C 2 Replies Last reply
    0
    • C cstrader232

      I need to populate a DGV. I need to be able to index the rows of the DGV by a string variable. But I also need to have duplicate rows in the DGV. A collection allows me to index the rows the way I need to, but doesn't allow duplicate keys. Is there any other alternative? Thanks

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, what collection are you using? some of them (such as List) don't care about unique items, others do (such as Dictionary which requires unique keys). :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.


      C 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, what collection are you using? some of them (such as List) don't care about unique items, others do (such as Dictionary which requires unique keys). :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.


        C Offline
        C Offline
        cstrader232
        wrote on last edited by
        #3

        Hello, Dim Mycollection as new collection Are you saying I should be looking into List(of)? Thanks!

        C 1 Reply Last reply
        0
        • C cstrader232

          Hello, Dim Mycollection as new collection Are you saying I should be looking into List(of)? Thanks!

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          you should ALWAYS use typed containers.

          Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

          1 Reply Last reply
          0
          • C cstrader232

            I need to populate a DGV. I need to be able to index the rows of the DGV by a string variable. But I also need to have duplicate rows in the DGV. A collection allows me to index the rows the way I need to, but doesn't allow duplicate keys. Is there any other alternative? Thanks

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            if you're using a hashtable, you can make the key map to a list of items, then you can add duplicates there.

            Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

            C 1 Reply Last reply
            0
            • C Christian Graus

              if you're using a hashtable, you can make the key map to a list of items, then you can add duplicates there.

              Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

              C Offline
              C Offline
              cstrader232
              wrote on last edited by
              #6

              "Make the key map to a list of item" sounds like what I want, but how? I map my collection (maybe a hashtable) to the DGV Each item in the collection represents a separate row in the DGV I write to the collection through the key. Ideally, more than one row could have the same key and would all be written to in the same set. But collections, hashtables too, require unique keys. What am I missing? Thanks again.

              L 1 Reply Last reply
              0
              • C cstrader232

                "Make the key map to a list of item" sounds like what I want, but how? I map my collection (maybe a hashtable) to the DGV Each item in the collection represents a separate row in the DGV I write to the collection through the key. Ideally, more than one row could have the same key and would all be written to in the same set. But collections, hashtables too, require unique keys. What am I missing? Thanks again.

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                You could create a Dictionary< string, List< someThing>> which would map each string onto a List holding zero, one, or more objects of type someThing. :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.


                C 1 Reply Last reply
                0
                • L Luc Pattyn

                  You could create a Dictionary< string, List< someThing>> which would map each string onto a List holding zero, one, or more objects of type someThing. :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.


                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  Yes, that's what I was trying to say :P

                  Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                  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