Solved

VB 2008  - Attempting to select all DataGridView rows

Posted on 2009-07-09
5
446 Views
Last Modified: 2012-05-07
I am attempting to select all the grid's rows but failing.  I just don't know how to write this code.

Although the grid is named  EvalItemsDataGridView the design-time compiler says it "is not a collection type".

        For Each row As DataGridViewRow In EvalItemsDataGridView
            DataGridViewRow.CurrentRow.Selected = True
        Next
0
Comment
Question by:ljcor
[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
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:divyeshhdoshi
ID: 24812261
Hi,


In asp.net gridview you can not select multiple rows at a time. If you try to do  so
using
        For Each row As DataGridViewRow In EvalItemsDataGridView
            DataGridViewRow.CurrentRow.Selected = True
        Next


then it will select last selected row.

To select multiple rows you need to extend functionality of gridview.
http://www.codeproject.com/KB/aspnet/Extend_GridView.aspx
http://www.aspnetworld.com/articles/2007041601.aspx
0
 

Author Comment

by:ljcor
ID: 24812298
OK, but let's start with the VB problem I mention in the initial question:  what is wrong with the portion of the statement: EvalItemsDataGridView - when that is the name of the grid?
0
 
LVL 6

Accepted Solution

by:
divyeshhdoshi earned 250 total points
ID: 24812338
Datagrid is not a collection

for that you need to specify

        For Each row As DataGridViewRow In EvalItemsDataGridView.Rows
            DataGridViewRow.CurrentRow.Selected = True
        Next
0
 
LVL 47

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 250 total points
ID: 24812410
To select all rows, simply use this....

    DataGridView1.SelectAll()

Wayne
0
 

Author Closing Comment

by:ljcor
ID: 31601511
Both responses are very helpful to me for other work.  Thanks to each of you.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

687 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