• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 765
  • Last Modified:

MultiSelect DataGridView

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
sherbug1015
Asked:
sherbug1015
  • 4
  • 2
1 Solution
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
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
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
This is for one column ...You should add one more loop
For Col=0 to Me.DatagridView.Column.Count-1  

Next
0
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
Also you have to set MultiSelect Propertyto true
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
sherbug1015Author Commented:
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
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
You have to set selectionMode FullRowSelect,And Multiselect to true
0
 
sherbug1015Author Commented:
OK.  I didn't know about the FullRowSelect.  Thanks a bunch.  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now