[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 735
  • 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

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