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!

Flexgrid .MouseCol issue 1

Status
Not open for further replies.

WBH1138

Programmer
May 31, 2002
85
GB
Hi

I'm using a flexgrid and the number of columns goes past the visible area of the grid.

In the grid's Click event I have a subroutine that selects data from the column clicked on by using .mousecol.
When clicking on the last visible column, which is wider than the remaining visible area for the grid, the .mousecol value is one more than the clicked column, and the clicked column is no longer the last visible column. The next one is.

This only happens when the scroll bar is as far left as it will go (i.e. initial position)

I presume the grid is moving the columns across as it is clicked and registering the new last visible column.

Is there a way to get round this so I can get the column I want?

Thanks
 

You can capture MouseCol in MouseDown event and use it in Click event.

I placed a MSFlexGrid1 and Label1 on the Form, and run this code, Label1 shows the correct MouseCol even tho FlexGrid 'moves' one column away like in your example:
Code:
Option Explicit
Dim i As Integer
Dim intMouseCol As Integer

Private Sub Form_Load()
    With MSFlexGrid1
        .Cols = 10
        .Rows = 25
        For i = 0 To MSFlexGrid1.Cols - 1
            MSFlexGrid1.TextMatrix(1, i) = i
        Next i
    End With
End Sub

Private Sub MSFlexGrid1_Click()
    Label1.Caption = intMouseCol
End Sub

Private Sub MSFlexGrid1_MouseDown(Button As Integer, _
    Shift As Integer, x As Single, y As Single)
    
    intMouseCol = MSFlexGrid1.MouseCol
End Sub
Maybe somebody else will have a better 'work wround' for this.....

Have fun.

---- Andy
 
Thanks

never thought of mousedown. That's sorted my issue.

Cheers Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top