Einzelnen Beitrag anzeigen

Benutzerbild von Lannes
Lannes

Registriert seit: 30. Jan 2005
Ort: Münster
745 Beiträge
 
Delphi 3 Professional
 
#9

Re: StringGrid Farbe einzelner Wörter in einzelnen Zellen de

  Alt 5. Dez 2005, 20:19
Hallo,

ein kleines Beispiel zum Einstieg.
Der Code formatiert das erste Wort in jeder nicht fixierten Zelle in Fettschrift, die restlichen Worte werden in blauer Farbe gesetzt.
Delphi-Quellcode:
procedure TForm1.GridDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var s : String;
    x : integer;
begin
  with StringGrid1 do
    if not (gdFixed in State) then
    if Pos(' ',Cells[ACol,ARow]) > 0 then
      begin
      s := Copy(Cells[ACol,ARow],1,Pos(' ',Cells[ACol,ARow])-1);
      Canvas.Font.Style := [fsBold];
      Canvas.TextOut(Rect.Left+2,Rect.Top+2,s);
      x := Canvas.TextWidth(s);
      Canvas.Font.Style := [];
      Canvas.Font.Color := clBlue;
      s := Copy(Cells[ACol,ARow],Pos(' ',Cells[ACol,ARow]),MAXINT);
      Canvas.TextOut(Rect.Left+2+x,Rect.Top+2,s);
      end;
end;
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
  Mit Zitat antworten Zitat