Dbgrid fields have Duplicate Text

Asked

Viewed 280 times

1

I’m gonna put on the picture first to see if any of you know how to fix this. inserir a descrição da imagem aqui

As you can see when the line is selected the testo is duplicated and prevents the visualization of information. I am used Delphi 10.1 Berlin. I have that same code on Delphi 7 and it works Perfect... (Weird)

in the event "dbgCentroCustoDrawColumnCell" I line up the text of the Columns Cost Center and Description

procedure TfrmCentroCusto.dbgCentroCustoDrawColumnCell(Sender: TObject;          const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
  Format: integer; {poderá utilizar:FmtCentered,FmtLeft,FmtRight,taLeftJustify,taCenter,taRightJustify}
  R: TRect;
begin
  Format := 0;
{$REGION '  CODIGO CENTRO CUSTO '}
  if (dbgCentroCusto.Columns[datacol].Field.FieldName =  'CODIGO_CENTRO_CUSTO') then
  begin// 1º Nivel
    if  (Copy(DataModuleGeral2.qryPesquisaCentroCustoCODIGO_CENTRO_CUSTO.AsString,4,8) =  '00.00') then
    begin
      R := Rect;
      Format := FmtLeft;
      dbgCentroCusto.Canvas.FillRect(Rect);
      dbgCentroCusto.Canvas.Font.Style := [fsbold];
    end else// 2º Nivel
    if (dbgCentroCusto.Columns[datacol].Field.FieldName = 'CODIGO_CENTRO_CUSTO') and      ((Copy(DataModuleGeral2.qryPesquisaCentroCustoCODIGO_CENTRO_CUSTO.AsString,4,8)>'00')and(Copy(DataModuleGeral2.qryPesquisaCentroCustoCODIGO_CENTRO_CUSTO.AsString,7,8)='00'))then
    begin
      R := Rect;
      Format := FmtCentered;
      dbgCentroCusto.Canvas.FillRect(Rect);
      dbgCentroCusto.Canvas.Font.Style := [fsbold];
      dbgCentroCusto.Columns[0].Alignment := taCenter;
    end else // 3º Nivel
    if (dbgCentroCusto.Columns[datacol].Field.FieldName='CODIGO_CENTRO_CUSTO') then
    begin
      R := Rect;
      Format := FmtRight;
      dbgCentroCusto.Canvas.FillRect(Rect);
      dbgCentroCusto.Columns[0].Alignment := taRightJustify;
    end;
  // Aplica as mudanção no visual da Grid:         Conteudo do Celula          Tamanho do Conteudo do Celula           Alinhamento
  DrawText(dbgCentroCusto.Canvas.Handle, PChar(' '+Column.Field.AsString+' '), Length (' '+Column.Field.AsString+' '), R, Format);
end;

This is only a part because for the Description Field repeats the above...

  • Hello, I’m having similar problem. You found a solution?

  • Not yet I preferred to change Drawingstyle to gdsClassic and not have this headache...

1 answer

1

  • I’ve already been there. He even asked me to pass my code and to this day did not answer. ...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.