0

I need to do something in the MyFlexGrid_DblClick(), but only if the back color is NOT set to vbInactiveBorder, I tried the folowing code but had no succes

Private Sub MyFlexGrid_DblClick()  

    If Not MyFlexGrid.BackColor = vbInactiveBorder Then  
        _what I need to do_  
    End If

End Sub

During debuging the inside "what I need to do" works perfectly, but the check in If is always true, even when the backcolor of the cell I'm double clicking is previously set to vbInactiveBorder.

Deanna
  • 23,876
  • 7
  • 71
  • 156
  • Have you tried checking the cell's background colour rather than the whole grid's? What are you doing to set the cell's background colour? – Deanna Mar 13 '13 at 14:40
  • Are you sure that `.BackColor` is the cell's background colour? It's the [default background colour](http://msdn.microsoft.com/en-us/library/aa228900(v=vs.60).aspx) here with [`.CellBackColor`](http://msdn.microsoft.com/en-us/library/aa239821(v=vs.60).aspx) being the cell's background colour. "BackColor affects the color of all non-fixed cells. To set the background color of individual cells, use the CellBackColor property." – Deanna Mar 13 '13 at 14:56
  • Yes, it's .cellbackcolor now it works perfectly! thenak you very much @Deanna – Andres Weber Mar 13 '13 at 14:59

1 Answers1

2

You're checking the wrong property.

.BackColor refers to the default background colour of cells. Try checking .CellBackColor to get the current cell's background colour.

From MSDN:

BackColor affects the color of all non-fixed cells. To set the background color of individual cells, use the CellBackColor property.

Deanna
  • 23,876
  • 7
  • 71
  • 156