Peter Dzomlija

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: TRzDBGrid.QuickCompare #2665
    Peter Dzomlija
    Participant

      Pity…😑

      in reply to: TRzDBGrid.QuickCompare #2636
      Peter Dzomlija
      Participant

        Thanks Ray. You have been a great help.

        Since my last reply, I have learned that I can use

        TDBGrid(Sender).DataSource.DataSet.FieldValues[DataModule1._FXQueryBusy.FieldName];

        to determine the appropriate values of other fields.

        The following code is what I use for <u>OnDrawColumnCell</u>. Perhaps it will be off assistance to others who have a similar:

        procedure TFormMain.DBGridDataDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
              procedure DrawBooleanValue(AValue:Boolean; AImageIndex:Integer; AFieldName:string);
              begin
                if (CompareText(Column.Field.FieldName, AFieldName)=0) then
                  if AValue then
                    ImageListGrid.Draw(DBGridData.Canvas, Rect.Left+((Rect.Width - ImageListGrid.Width) div 2),
                                                          Rect.Top+((Rect.Height - ImageListGrid.Height) div 2), AImageIndex);
              end;
        begin
          with Sender as TDBGrid do
            if DataSource.DataSet.RecordCount > 0 then
              begin
                {Row Background}
                if (gdSelected in State) or (gdRowSelected in State) then
                  Canvas.Brush.Color := clHighlight
                else
                  if Odd(DataSource.DataSet.RecNo) then
                    Canvas.Brush.Color := clWindow
                  else
                    Canvas.Brush.Color := $00FAFAFA;
        
                Canvas.FillRect(Rect);
        
                {Cell Values}
                if not Assigned(Column.Field) then
                  DefaultDrawColumnCell(Rect, DataCol, Column, State)
                else
                  {Boolean Fields must be drawn using a TImagelist glyph}
                  if Column.Field.InheritsFrom(TBooleanField) then with TBooleanField(Column.Field) do
                    begin
                      DrawBooleanValue(not Value, 1, DataModule1._FXIsValid.FieldName);
                      DrawBooleanValue(Value, 0, DataModule1._FXBusy.FieldName);
                    end
                  else
                    {Change the font style/color}
                    with DataModule1, Column.Field do
                      begin
                        if not DataSource.DataSet.FieldValues[DataModule1._FXIsValid.FieldName] then
                          begin
                            Canvas.Font.Style := [fsStrikeOut];
                            Canvas.Font.Color := IfThen(gdSelected in State, clHighLightText, clRed);
                          end
                        else
                          if DataSource.DataSet.FieldValues[DataModule1._FXBusy.FieldName] then
                            begin
                              Canvas.Font.Style := [fsItalic];
                              Canvas.Font.Color := IfThen(gdSelected in State, clHighLightText, clGreen);
                            end
                          else
                            begin
                              Canvas.Font.Style := [];
                              Canvas.Font.Color := IfThen(gdSelected in State, clHighLightText, clWindowText);
                            end;
        
                        {Continue Drawing}
                        DefaultDrawColumnCell(Rect, DataCol, Column, State);
                      end;
              end
            else
              DefaultDrawColumnCell(Rect, DataCol, Column, State);
        end;
        

        Off-Topic P.S:<i>Is there any way to get the Raize/Konopka controls installed into Delphi Community Edition 10.4?</i> 🤔 I can’t use 10.4 CE for my primary project, because it makes extensive use of Raize. So I have to continue using 10.1 Berlin….

        in reply to: TRzDBGrid.QuickCompare #2599
        Peter Dzomlija
        Participant

          For for your response, Ray.

          This is a sample use of “OnDrawColumnCell”:
          OnDrawColumnCell

          It works well enough to replace the “TRUE / FALSE” displayed by Boolean fields with a checkmark glyph.

          But as far as I can tell, “OnDrawColumnCell” only gives me access to the value of the field that is being drawn, and not the entire record represented by the row. So if I’m drawing a string field, I cannot check the value of a boolean field in the same record, which means I can’t change the font style to (for example) “Red, StrikeOut” or “Green, Italic” based upon the values of other fields in the same record…

          Or have I missed something? 🤔

        Viewing 3 posts - 1 through 3 (of 3 total)