PDA

Click to See Complete Forum and Search --> : MSFlexGrid Question (simple, I hope)


BruceG
Jul 11th, 2000, 02:25 PM
Note: I am posting this in both the General and Database forums.

Scenario: I've got an MSFlexGrid bound to a DataControl pointing to a particular table in an Access database. I've got the grid set up to select by row. The user can select multiple rows (contiguous only) by dragging with the mouse; this is fine.

Having hardly ever used the MSFlexGrid control, I am unfamiliar with how to use its numerous properties. All I want to do is the following:
(1) Find what rows the user selected
(2) Extract data from particular cells in those selected rows.

Can someone give me hand? Thanks in advance.

CGTS
Jul 11th, 2000, 08:22 PM
Try something like the following...........

------------------------------------------------------------
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim sRow As Integer ' Set to Start Row
Dim eRow As Integer ' Set to End Row
Dim i As Integer ' index for loop
Dim temp As Integer ' used in smallest row first code
Dim YourColumn As Integer ' an integer to hold your required column index

YourColumn = 2 ' some arbitary figure for testing

With MSHFlexGrid1
sRow = .Row
eRow = .RowSel

If sRow > eRow Then ' It's best to make sure startrow is always the smallest value so you
temp = sRow ' can use a for next loop
sRow = eRow
eRow = temp
End If

For i = sRow To eRow
Debug.Print .TextMatrix(i, YourColumn)
Next i
End With
End Sub
------------------------------------------------------------

I have just used a loop to show the results. You obviously can modify this to get whatever column data you require.

BruceG
Jul 11th, 2000, 08:56 PM
Beautiful! I appreciate your response, and you provided some additional information to what I subsequently discovered on my own (see my post for this question on the General forum). Thanks again!