check if cell contain image or icon

User avatar
sal21
PlatinumLounger
Posts: 4343
Joined: 26 Apr 2010, 17:36

check if cell contain image or icon

Post by sal21 »

I use this code in mousemove event in msflexgrid...

how to insert into the IF condition, a new condition, if mouse is on a filled cell with icon or image, else no action...

Code: Select all

 If COLONNA >= 1 And COLONNA <= LASTDAY And RIGA >= 1 And ANNO > Empty And MESE > Empty Then

Code: Select all

Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)

    With Me.MSFlexGrid1
        Me.LCOLONNA.Caption = .MouseCol
        Me.LRIGA.Caption = .MouseRow
        COLONNA = Me.LCOLONNA.Caption
        RIGA = Me.LRIGA.Caption
        If COLONNA >= 1 And COLONNA <= LASTDAY And RIGA >= 1 And ANNO > Empty And MESE > Empty Then
            Me.LGIORNO.Caption = UCase(Format(DateSerial(ANNO, MESE, COLONNA), "DDD")) & "-" & DateSerial(ANNO, MESE, COLONNA)
            TIPO = .TextMatrix(RIGA, 0)
            '.Rows = RIGA
            '.Cols = 0
            'TIPO = .TextMatrix(1, 1)
            Call TROVA_IN_ARRAY(TIPO)
            'Debug.Print TIPO
        Else
            Me.LGIORNO.Caption = ""
            Me.LSTANZA.Caption = ""
            DoEvents
        End If
    End With

End Sub
note:
in my case the icon/image is the green flag
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78391
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: check if cell contain image or icon

Post by HansV »

Does this work?

Code: Select all

Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)

    With Me.MSFlexGrid1
        Me.LCOLONNA.Caption = .MouseCol
        Me.LRIGA.Caption = .MouseRow
        COLONNA = Me.LCOLONNA.Caption
        RIGA = Me.LRIGA.Caption
        .Row = RIGA
        .Col = COLONNA
        If COLONNA >= 1 And COLONNA <= LASTDAY And RIGA >= 1 And ANNO > Empty And MESE > Empty And (.Text <> "" Or Not .CellPicture Is Nothing) Then
            Me.LGIORNO.Caption = UCase(Format(DateSerial(ANNO, MESE, COLONNA), "DDD")) & "-" & DateSerial(ANNO, MESE, COLONNA)
            TIPO = .TextMatrix(RIGA, 0)
            Call TROVA_IN_ARRAY(TIPO)
        Else
            Me.LGIORNO.Caption = ""
            Me.LSTANZA.Caption = ""
            DoEvents
        End If
    End With

End Sub
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4343
Joined: 26 Apr 2010, 17:36

Re: check if cell contain image or icon

Post by sal21 »

HansV wrote:
01 Jul 2021, 11:26
Does this work?

Code: Select all

Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)

    With Me.MSFlexGrid1
        Me.LCOLONNA.Caption = .MouseCol
        Me.LRIGA.Caption = .MouseRow
        COLONNA = Me.LCOLONNA.Caption
        RIGA = Me.LRIGA.Caption
        .Row = RIGA
        .Col = COLONNA
        If COLONNA >= 1 And COLONNA <= LASTDAY And RIGA >= 1 And ANNO > Empty And MESE > Empty And (.Text <> "" Or Not .CellPicture Is Nothing) Then
            Me.LGIORNO.Caption = UCase(Format(DateSerial(ANNO, MESE, COLONNA), "DDD")) & "-" & DateSerial(ANNO, MESE, COLONNA)
            TIPO = .TextMatrix(RIGA, 0)
            Call TROVA_IN_ARRAY(TIPO)
        Else
            Me.LGIORNO.Caption = ""
            Me.LSTANZA.Caption = ""
            DoEvents
        End If
    End With

End Sub
is this code correct if a cell have an icon or image:

...
.Row = RIGA
.Col = COLONNA
If Not .CellPicture Is Nothing Then
Stop
End if
...

User avatar
HansV
Administrator
Posts: 78391
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: check if cell contain image or icon

Post by HansV »

I think so, but as you know, I cannot test it.
Best wishes,
Hans