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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flex Grid trouble... 2

Status
Not open for further replies.

graphix03

Technical User
Oct 8, 2003
189
US
Hi, i have the blocks of code below,
and I'm not sure what I do wrong, but
i want to be able to click on the
navigation button to move through
the record, but it also will highligh
on the grid for that same record navigated.

The code below seems to work but it will
highlight 2 rows at the same time -- the
row I click the first time and the row
I click next or previous.

let me know if I confuse you. thanks much for any input.

Private Sub GridHistory_Click()
Dim i As Integer
Dim x As Integer
x = gridHistory.Row
gridHistory.SelectionMode = flexSelectionByRow
With gridHistory
For i = 1 To x
txtCodeOrder.Text = gridHistory.TextMatrix(i, 1)
txtCodeID.Text = gridHistory.TextMatrix(i, 2)
txtCodeDesc.Text = gridHistory.TextMatrix(i, 3)
Next
End With

End Sub


Private Sub NavigateButtons(bVal As Boolean)
Dim i As Integer
For i = 0 To 3
cmdNavigate(i).Enabled = bVal
Next
End Sub


Private Sub cmdNavigate_Click(Index As Integer)
Dim II As Integer
Dim FF As Integer

FF = gridHistory.Row
gridHistory.HighLight = flexHighlightAlways

With gridHistory
Select Case Index
'First
Case 0
.Row = 1
Call GridHistory_Click
For II = 0 To .Cols - 1
.RowSel = FF
.ColSel = II
Next

'Previous
Case 1
.Row = .Row - 1
Call GridHistory_Click
For II = 0 To .Cols - 1
.RowSel = FF
.ColSel = II
Next

'Next
Case 2
.Row = .Row + 1
Call GridHistory_Click
For II = 0 To .Cols - 1
.RowSel = FF
.ColSel = II
Next

'Last
Case 3
.Row = .Rows - 1
Call GridHistory_Click
For II = 0 To .Cols - 1
.RowSel = FF
.ColSel = II
Next

End Select

End With

End Sub
 
When you click next, previous or last, your code RESETS .Row to where it was previously, and does not set it back to where it belongs (the new row). When you select in a grid, the selection is FROM the current row (.Row) TO the select row (.RowSel). You need to RESET .ROW back to it value when cmdNavigate_Click was called.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
oh, okay, thanks Tracy tsdragon. let me try that. thanks so much.
 
graphix03,

I rewrote one of the events so it should work now:

Private Sub cmdNavigate_Click(Index As Integer)
Dim II As Integer
Dim FF As Integer

With GridHistory
FF = .Row
.HighLight = flexHighlightAlways
.FocusRect = flexFocusNone
.SelectionMode = flexSelectionByRow
End With

With GridHistory
Select Case Index
'First
Case 0
.Row = 1
.RowSel = 1

'Previous
Case 1
If .RowSel > 0 Then
.RowSel = .RowSel - 1
.Row = .Row - 1
End If

'Next
Case 2
If .RowSel < .Rows - 1 Then
.RowSel = .RowSel + 1
.Row = .Row + 1
End If

'Last
Case 3
.RowSel = .RowSel - 1
.Row = .Rows - 1

End Select

GridHistory_Click

For II = 0 To .Cols - 1
.ColSel = II
Next

End With

End Sub

vladk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top