Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MultiSelect DataGridView

Posted on 2010-09-11
6
Medium Priority
?
688 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 2000 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

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

721 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