Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through selected rows in ultragrid

Status
Not open for further replies.

HezMac

Programmer
Jan 14, 2004
56
CA
Hello

I'd like to loop through selected rows in an ultragrid and get the value of one cell.

I'm having difficulty figuring out how to do this, as well as finding ANY documentation on how to do it.

I've tried so many scenarios, but here's some of the code:

Code:
Dim rowCount As Integer
Dim i As Integer
Dim RSNInt As Integer
Dim RSNStr As String
Dim FolderRSN As String
Dim RemoveFolders As String
Dim aRow as SSRow

'Format RemoveFolders string like "(1)FolderRSN1,(2)FolderRSN2,(3)FolderRSN3,"

For i = 0 To gridPending.Selected.Cells.Count - 1
   Set aRow = gridPending.Selected.Cells
   RSNInt = RSNInt + 1
   RSNStr = Trim(Str(RSNInt))
   FolderRSN = aRow.Cells(3).Value
   RemoveFolders = FolderRSN + "(" + RSNStr + ")" + FolderRSN + ","
Next

I'm not even sure how to get the selected rows, as the gridPending.Selected.Cells doesn't work!!

Any suggestions? Thanks.
 
I'm not familiar with that control but don't you need
Code:
Set aRow = gridPending.Selected.Cells[b][COLOR=red](n)[/color][/b]
 
Thanks for the thought, but no change.
 
Got it figured out. Here is what works for me, if anyone else is interested.

Golom: you were right, I needed to reference '0' where I wasn't referencing anything.

Code:
Private Sub cmdRemovePending_Click()

    Dim aRow As SSRow
    Dim cellCount As SSRow
    Dim FolderRSN As String
    Dim RemoveFolders As String
    Dim resstr As String
    Dim response As String
    Dim rowCount As Integer
    Dim RSNInt As Integer
    Dim RSNStr As String

    'Count the number of rows selected
    rowCount = gridPending.Selected.Rows.Count
    Debug.Print "# rows selected: " & rowCount
    
    'Verify removal of the reassigns
    resstr = "Are you sure you want to remove the selected " & rowCount & " account(s) from the reassign?"
    response = MsgBox(resstr, vbYesNo, "Remove Accounts")
    
    If response = vbYes Then

        For Each cellCount In gridPending.Selected.Rows
        
            RSNInt = RSNInt + 1
            RSNStr = Trim(Str(RSNInt))
            Set aRow = gridPending.Selected.Rows.Item(0)
            FolderRSN = aRow.Cells(3).Value
            RemoveFolders = RemoveFolders + "(" + RSNStr + ")" + FolderRSN + ","
            Debug.Print RemoveFolders
            
        Next
        
    Else
        'Do nothing
    End If
    
End Sub

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top