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!

MSFLEXGRID auto scrolls to top when Click+Drag on a fixed hdr cell

Status
Not open for further replies.

BruceBussell

Programmer
Jul 14, 2003
49
US
I have encountered a problem where my VB6 MSFLEXGRID auto scrolls to the top row in the grid when one does Mouse Click+Drag on a fixed hdr cell in the first row = 0, and the grid has been previously scrolled down manually so the top visible row is not the actual first row in the grid.

The Mouse Down event is executed before the auto scrolling starts, but I have not found a way to use this to intercept and prevent the auto scrolling to the top row in the grid while one has the mouse pressed down on a fixed header cell in row 0.

Does any one know a way to prevent this problem from ocurring.

 
You can try this solution, however it may not be very elegant. I have got this to work under most circumstances.

Declare two modular variables/flags.

Private m_intTopRow As Integer
Private m_bolHeaders As Boolean

Place the following code in the flexgrids mousemove and scroll events.

Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If MSFlexGrid1.MouseRow = 0 Then
m_bolHeaders = True
m_intTopRow = MSFlexGrid1.TopRow
Else
m_bolHeaders = False
End If
End Sub

Private Sub MSFlexGrid1_Scroll()
If m_bolHeaders Then MSFlexGrid1.TopRow = m_intTopRow
End Sub


Thanks and Good Luck!

zemp
 
A note for zemp.

Your proposed solution works pretty well, although as you noted, it is not real elegant.

However, I had to modify the following section in the Private Sub MSFlexGrid1_Scroll() procedure as follows:

If m_bolHeaders Then
vsFlexArray1.TopRow = m_intTopRow
m_bolHeaders = False
End If

This was because I could not get my Vertical Scroll bars to work again after doing Mouse Down and then Drag on my MSFlexGrid header row, which ran through this code.

So I had to add "m_bolHeaders = False" as noted above to get my Vertical Scroll bars to work again.

Thanks for the tip.

Bruce Bussell

 
Thanks for pointing that out. The flag does need to be reset every time the scroll event fires or it won't be ready for the next time you move your mouse.

Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top