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

Flexgrid with vertical scroll bar 1

Status
Not open for further replies.

Bluejay07

Programmer
Mar 9, 2007
780
CA
Hello,

This is an old subject but I can't seem to find the answer.

I am using a flexgrid with a vertical scroll bar. How do I determine if the up was clicked, the down was clicked or somewhere in between.

I have tried the scroll function, however, the top row property is already changed at this point and is no good if I don't know what the top row was before clicking the scroll bar.

The reason I am asking is for cell focus. If the user is in cell B and clicks the up arrow of the scroll bar, I will change focus to cell A. Contrary, if the down arrow is clicked, I will set focus to cell C. If any other section of the scroll bar is clicked, no cell is to get the focus.

Could anyone help me to sort this out please?
Thanks.
 
In the Scroll event why not declare a Static variable for holding the previous top row so that you can compare it against the new top row when the event fires?

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Hi Andy,

Thanks for the reply. After reading your comment, I re-looked at some possibilities and came up with a solution that seems to be working.

Code:
Private Sub flgCodes_Scroll()

   Dim l_intPos As Integer
   
   l_intPos = flgCodes.Row
   flgCodes.Row = 0   'Ensures leavecell and entercell events will be fired.  Row 0 is a fixed row.
   
   If m_intPos = flgCodes.TopRow + 1 Then
      flgCodes.Row = l_intPos - 1
   ElseIf m_intPos = flgCodes.TopRow - 1 Then
      flgCodes.Row = l_intPos + 1
   Else
      'do nothing
   End If
   
   m_intPos = flgCodes.TopRow
   
End Sub

The variable m_intPos is initially set when the form loads.

I'm sure there are better ways to handle this, however, my current solution works.

Thanks for the suggestion.
 
Thanks.

The only thing you might want to check in your code is that the value might not always increase or decrease by 1. If the user drags the scrollbar or clicks to move it a page at a time the difference between the previous and new values is likely to be more than 1.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
If the user clicks a random position, the else case (nothing happens) takes over. How would you suggest handling if the user clicks and drags the scroll position?
 
I modified the code as follows and it seems OK in either situation.

Code:
   If m_intPos = flgCodes.TopRow + 1 Then
      [COLOR=red]If l_intPos > 1 Then[/color]
         flgCodes.Row = l_intPos - 1
      End If
   ElseIf m_intPos = flgCodes.TopRow - 1 Then
      flgCodes.Row = l_intPos + 1
   Else
      'do nothing
   End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top