Forum Discussion

RodrigoJr's avatar
RodrigoJr
Occasional Contributor
7 years ago

Capture a background color and font color of the line in DBGrid

I have a functionality in the DBGrid when selecting a row and press a key this changes the background color and font color of the row has ben selected. The validation i need to apply is if pressing the key actually occurs this color change. I have done some tests with the property ".Canvas.Font.Color", however it is not changing this property at runtime, it always returns the same color. However in debug the execution some times it changes, has anyone done any such validation or have any ideia how i do that?

  • Next thing to try... just as a test...  what happens if, before you do the check for color, you put in a delay call... delay like 2000 milliseconds (2 seconds) and see what happens?  Could this be a timing issue where there is a time delay JUST enough that the validation is happening before the properties are updated?

  • karkadil's avatar
    karkadil
    Valued Contributor

    It looks like property doesn't refresh after the action has been performed. Try calling Refresh() method of the grid before checking the color.

    • RodrigoJr's avatar
      RodrigoJr
      Occasional Contributor

      I already used the refresh () before capturing the color, but the color is still wrong.
      :(

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        I wonder if it's a caching issue?  If it has the old object cached in memory?

        Try RefreshMappingInfo() before you do the check, actually let it refresh the object in cache.