Link to home
Start Free TrialLog in
Avatar of Bob Butcher
Bob ButcherFlag for United States of America

asked on

populating a label based on flex grid data using mouseover event

I have a flexgrid that I build with user data. If there is some user data in a cell, which I use the textmatrix and row and col to determine, I would like to display a label with some more user data if the cell isn't blank.

How can I display a label using the mouseover event if there is text in a cell and hide if there isn't.

Also, how can I position the label control based on where I am on the screen so the label control is close to the cell?

A snippet of code would be terrific.

Thanks!
Avatar of PaulHews
PaulHews
Flag of Canada image

This code shows how to populate a label from the mousemove event.  However, I don't move the label, as a label cannot appear in front of the grid (label is a windowless control.)  I also show how to use the tooltip of the flexgrid if you wish to use that instead of a label, as that moves where the mouse goes.  You can see when the tooltip is empty, it doesn't show up.
Option Explicit
 
Private Sub Form_Load()
    Dim i As Integer
    MSFlexGrid1.Rows = 0
    MSFlexGrid1.Cols = 3
    For i = 1 To 10
        If i <> 5 Then
            MSFlexGrid1.AddItem "Test" & vbTab & i & vbTab & "Test"
        Else
            MSFlexGrid1.AddItem "" & vbTab & i & vbTab & ""
        End If
    Next
End Sub
 
Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    With MSFlexGrid1
    .ToolTipText = .TextMatrix(.MouseRow, .MouseCol)
    Label1.Caption = .TextMatrix(.MouseRow, .MouseCol)
    End With
End Sub

Open in new window

Avatar of Bob Butcher

ASKER

Almost exactly what I was looking for. I really need to pop up something, that is multi-lined, which rules out the tool tip. Perhaps a borderless form with a label in it. I need to present additional data to my customers that I don't want to cram in the flex grid cell. Could I do this and would this work?
My other concern is what if this form is already loaded, how would I check for that and repopulate it, and how can I position it on my screen so it isn't always in the middle (center) but maybe 10 px to the left of the grid I just moused over.
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much for your quick response.