Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Datagrid Select All

Posted on 2004-08-27
15
Medium Priority
?
185 Views
Last Modified: 2010-05-18
What code do i use to select all records in a datagrid
0
Comment
Question by:daverichardson
[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
  • 6
  • 6
15 Comments
 
LVL 7

Expert Comment

by:natloz
ID: 11917756
What do you mean select all records in a datagrid? Do you mean basically looping through the entire grid for values?
0
 

Author Comment

by:daverichardson
ID: 11917772
Yes
0
 
LVL 7

Expert Comment

by:natloz
ID: 11917854
dim intRowCount as integer = dgGrid.VisibleRowCount
dim intCount as integer = 0

If dgGrid.VisibleRowCount < 1 Then
            MsgBox("Nothing in GRID")
Else
            Dim oSelectedItem As Object
            Dim strBLAH As String

            Do while intCount < (intRowCount - 1)  <-----I used -1 because 30 Rows...means 0 to 29 for RowNumbers
                oSelectedItem = dgGrid.Item(intCount, 3) <--- 3 is any COLUMN Number you wish to read
                strBLAH = CStr(oSelectedItem)
                intCount = intCount + 1
            Loop            
End If
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:daverichardson
ID: 11917986
i dont know what i am missing but nothing happened

    Private Sub MnuSelectAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MnuSelectAll.Click
        Dim intRowCount As Integer = GrdOrders.VisibleRowCount
        Dim intCount As Integer = 0

        If GrdOrders.VisibleRowCount < 1 Then
            MsgBox("Nothing in GRID")
        Else
            Dim oSelectedItem As Object
            Dim strBLAH As String

            Do While intCount < (intRowCount - 1)
                oSelectedItem = GrdOrders.Item(intCount, 3)
                strBLAH = CStr(oSelectedItem)
                intCount = intCount + 1

            Loop
        End If
    End Sub
0
 
LVL 7

Expert Comment

by:natloz
ID: 11918006
Well....what do you want to do with the results? You will see what my solution is doing if you add

Do While intCount < (intRowCount - 1)
                oSelectedItem = GrdOrders.Item(intCount, 3)
                strBLAH = CStr(oSelectedItem)
                intCount = intCount + 1
                msgbox (strBlah)
            Loop

I am just showing you how to loop through the whole Grid and pick up results from each row.
0
 
LVL 7

Expert Comment

by:natloz
ID: 11918022
Well....what do you want to do with the results? You will see what my solution is doing if you add

Do While intCount < (intRowCount - 1)
                oSelectedItem = GrdOrders.Item(intCount, 3)
                strBLAH = CStr(oSelectedItem)
                intCount = intCount + 1
                msgbox (strBlah) <-------------- ADD THIS (Forgot to show you where adding)
            Loop

I am just showing you how to loop through the whole Grid and pick up results from each row.
0
 

Author Comment

by:daverichardson
ID: 11918068
that works but i want to highlight the rows so i can copy them
0
 
LVL 7

Expert Comment

by:natloz
ID: 11918081
What are you copying them to? All Columns are being copied including hidden ones?
0
 

Author Comment

by:daverichardson
ID: 11918096
i want to copy them to the clipboard
0
 

Author Comment

by:daverichardson
ID: 11923495
The easiest way to explain what I want is, within a Datagrid if you press ctrl-a to select the records and ctrl-c to copy but I want to do this with a menu
0
 
LVL 7

Accepted Solution

by:
natloz earned 200 total points
ID: 11946200
http://www.thecodeproject.com/csharp/PracticalGuideDataGrids4.asp#_Toc56951064

Goto section 5.5...I think this is what you are looking for...
0
 

Author Comment

by:daverichardson
ID: 11977885
Natloz this is exactly what i want, however i need it in vb not c

Dave
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

618 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