Thema: Delphi stringgrid Zellenrahmen

Einzelnen Beitrag anzeigen

Benutzerbild von ibp
ibp

Registriert seit: 31. Mär 2004
Ort: Frankfurt am Main
1.511 Beiträge
 
Delphi 7 Architect
 
#8

Re: stringgrid Zellenrahmen

  Alt 26. Sep 2005, 16:54
noch ne idee, erst eine zelle schwarz malen, dann mit einem kleineren rechteck nochmals übermalen!


Delphi-Quellcode:
procedure TForm1.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  aRect:TRect;
  str:string;
begin
  str:='Müller';

  if (StringGrid.Cells[ACol,ARow]=str) then
  begin
    StringGrid.Canvas.Brush.Color := clBlack;
    StringGrid.Canvas.FillRect(Rect);
    StringGrid.Canvas.Brush.Color := clBlue;
    aRect.Left:=Rect.Left+2;
    aRect.Top:=Rect.Top+2;
    aRect.Right:=Rect.Right-2;
    aRect.Bottom:=Rect.Bottom-2;

    if ACol<StringGrid.ColCount then
      if (StringGrid.Cells[ACol+1,ARow]=str) then
        aRect.Right:=Rect.Right;
    if ACol>StringGrid.FixedRows then
      if (StringGrid.Cells[ACol-1,ARow]=str) then
        aRect.Left:=Rect.Left;

    StringGrid.Canvas.FillRect(aRect);
    DrawText(StringGrid.Canvas.Handle,
               pChar(str),
               Length(str),
               Rect,DT_Center or DT_VCENTER or DT_SINGLELINE);
  end;

end;
...du musst nur noch wenn die ganzen daten eingefügt wurden, dass grid neu zeichnen lassen...
Miniaturansicht angehängter Grafiken
gridbsp_612.png  
  Mit Zitat antworten Zitat