vb6msflexgrid

How to find the cell background color


Using Flexgrid

I want to check the background color of the particular cell...

Code

if flexgrid1.TextMatrix(1, 2).CellBackColor = vbCyan then
msgbox vbcyan
else
msgbox vbwhite
End if

The above code is showing error as "Invalid Qualifier"

Other way....

if flexgrid1.row = 1 and flexgrid1.col = 2 and  .CellBackColor = vbCyan then
    msgbox vbcyan
    else
    msgbox vbwhite
    End if

The above code not displayed message box

How to solve the problem...

What wrong in my code.


Solution

  • .CellBackColor gets/sets the color for the current .Row/.Col, so before asking, you have to set the .Row/.Col to the one you're looking at:

    With flexgrid1
       .Row = 1
       .Col = 2
       If .CellBackColor = vbCyan Then
          msgbox vbCyan
       Else
          msgbox vbWhite
       End If
    End With