Solved

MultiSelect DataGridView

Posted on 2010-09-11
6
640 Views
Last Modified: 2012-05-10
This is a 2 part question

First Part

I have a multi-select datagridview that has 2 columns.  I need to read the two columns of each selected item into an arraylist.  

Part 2

Can I create a Property typed as an ArrayList and save the ArrayList to that Property?



0
Comment
Question by:sherbug1015
  • 4
  • 2
6 Comments
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33654260
try this

        Dim ArrList As ArrayList = New ArrayList()

        Dim i As Integer = 0

        Dim Col as integer

        

        For i = 0 To Me.dataGridView1.SelectedRows.Count

            ArrayList.Insert(0, Me.dataGridView1.SelectedRows(i))



        Next

Open in new window

0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33654267
This is for one column ...You should add one more loop
For Col=0 to Me.DatagridView.Column.Count-1  

Next
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33654272
Also you have to set MultiSelect Propertyto true
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:sherbug1015
ID: 33654425
I am trying your solution, but I must be doing something wrong.

First I fill the datagridview with values

Then while holding down the Shift key I pick a couple of rows

Then I have a button and the click event code is

Dim ncount As Integer
        ncount = Me.DataGridView1.SelectedRows.Count
        MsgBox(ncount)

The MsgBox value is always 0 no matter how many rows I select

Any ideas why SelectedRows won't return a value?

Thanks
0
 
LVL 18

Accepted Solution

by:
John (Yiannis) Toutountzoglou earned 500 total points
ID: 33654456
You have to set selectionMode FullRowSelect,And Multiselect to true
0
 

Author Comment

by:sherbug1015
ID: 33654504
OK.  I didn't know about the FullRowSelect.  Thanks a bunch.  
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now