Einzelnen Beitrag anzeigen

Reinhard Kern

Registriert seit: 22. Okt 2006
772 Beiträge
 
#3

Re: Panelschrägkanten farbig? + Frage zu DrawGrid

  Alt 30. Sep 2007, 01:14
Zitat von peace:
Gibt es irgendeine Eigenschaft von Panel die es mir erlaubt die Farbe der Schrägkante zu ändern?

zusätzlich: Wie kann man bei DrawGrid einzelne Felder ansprechen und ihre Farbe ändern?

mfg peace
Bei einem TDrawGrid must du ja die Zelle sowieso in der Ereignisroutine OnDrawCell selbst zeichnen - da kannst du machen was du willst. Die Zellenadresse wird ja als Parameter übergeben. Das sieht z.B. so aus:

Delphi-Quellcode:
procedure TBLMainForm.SG_OverviewDrawCell (Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var CSVal : integer;
    CSText : string[16];
    tw,th,tx,ty : integer;
begin
if (ACol = 3) and (ARow > 0) then
  with TStringGrid(Sender).Canvas do
    begin
    Brush.Color := clWindow;
    FillRect (Rect);
    TryStrToInt (TStringGrid(Sender).Cells [ACol,ARow],CSVal);
    case CSVal of
      1 : begin Font.Color := clRed; CSText := 'offline'; end;
      2 : begin Font.Color := clGreen; CSText := 'online'; end;
      3 : begin Font.Color := clGreen; CSText := 'Projekt'; end;
      else begin Font.Color := clBlack; CSText := 'inaktiv'; end;
      end;
    tw := TextWidth (CSText);
    th := TextHeight (CSText);
    tx := (Rect.right - Rect.Left - tw) div 2;
    ty := (Rect.bottom - Rect.Top - th) div 2;
    TextRect (Rect,Rect.Left + tx,Rect.top + ty,CSText);
    end;
if (ACol = 4) and (ARow > 0) then
  {...}
(in der 3. Spalte wird statt des Zellinhalts 0..3 ein farbiger Text angezeigt)

Gruss Reinhard
  Mit Zitat antworten Zitat