Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Datagrid Select All

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

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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 …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

810 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