DGV with duplicate rows
-
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
-
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
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.
-
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.
Hello, Dim Mycollection as new collection Are you saying I should be looking into List(of)? Thanks!
-
Hello, Dim Mycollection as new collection Are you saying I should be looking into List(of)? Thanks!
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
-
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
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
-
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
"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.
-
"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.
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.
-
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.
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