Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

TLMDDBGrid color a column

I have a TLMDDBGrid, and one of the columns contains a date.  I currently have this code


   if (AColumn->FieldName == "LastTimeHere")
   {
      AnsiString Data = AFormattedData.VOleStr;
      int Slash = Data.Pos("/");

      if (Slash)
      {
          // Code to determine if the date is in a certain range, if it is I want the background YELLOW

         // Want to make the cell background Yellow, this is where I need help!

         // With a normal TDBGrid           
         //Canvas->Brush->Color = clYellow;
         //DBGrid->DefaultDrawColumnCell(Rect, DataCol, Column, State);
 
         // I need to know how to do the DefaultDrawColumnCell with the LMD DBGrid
      }
   }

Thanks!
Doug




Comments

  • 2 Comments sorted by Votes Date Added
  • edited June 2015 Posts: 0Vote Up0Vote Down
    Hi,

    Regular TLMDGrid has OnGetCellColor event, which can be used in your scenario. However, I've forgot to publish the event in data-aware grid version. You can wait for the next minor release, or modify sources yourself; just add OnGetCellColor to TLMDDBGrid class as shown below:

    type
      TLMDGrid = class(TLMDCustomGrid)
      public
        //...
      published
        property OnGetCellColor;
        //...
      end;

    Then, if you can recompile packages - do it, and the event will be accessible at design-time; otherwise, temporarily, assign an event handler at run-time (e.g. inside OnFormCreate event handler).

    Eugene,
    LMD Innovative.
Sign In or Register to comment.