Listbox - Underline text when mouse hovers over cell

  1. last week

    I have a listbox with a popup menu when user clicks a canvas item (drawn button icon) in column 4. Prior to the user 'clicking', I'd like the canvas item to do 'something' visually on hover - similar to how a weblink auto-underlines on mouse over. Is there a simple way to do this with an event handler? I have been experimenting with MouseMove (and MouseEnter / MouseExit) to no avail. Was just going for simple text underline to start with (maybe utilizing ListBox.CellUnderline?) . Sorry if this has been answered a billion times, just haven't been able to find the answer in the forum.

    in MouseMove, determine the cell the mouse is over, set a flag to indicate which cell it is,
    invalidate that cell
    in the CellTextPaint, check if the cell being drawn and the cell in your flag are the same, if so, override the event and underline the text

  2. Dave S

    Dec 3 Answer San Diego, California USA

    in MouseMove, determine the cell the mouse is over, set a flag to indicate which cell it is,
    invalidate that cell
    in the CellTextPaint, check if the cell being drawn and the cell in your flag are the same, if so, override the event and underline the text

  3. Edited last week

    YES!!!!! Thank you! BTW, I dind't use a flag per se. I created 2 properties to store the mouse position as row/column. Is there a more efficient / better way to accomplish same? See my process below...

    In MouseMove.....

    mRow = Me.RowFromXY(X, Y)
    mCol = Me.ColumnFromXY(X, Y)
    Me.InvalidateCell(mRow, 4)

    in CellTextPaint.....

        Select Case column
        Case 4 
            g.DrawString("Lists", x, y)
            Me.CellUnderline(Row, column) = False  
            If row = mRow And column = mCol Then 
                   Me.CellUnderline(Row, column) = True
            End If
        Return True
        End Select
  4. 7 days ago

    Dave S

    Dec 3 San Diego, California USA

    that is pretty much what I was describing..... and the definintion of "flag" is open to interpetation

or Sign Up to reply!