Einzelnen Beitrag anzeigen

ZeroQool007

Registriert seit: 30. Aug 2004
127 Beiträge
 
#11

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

  Alt 6. Dez 2005, 12:27
@ Lannes

Hmmm...ich habe irgendwie ein Problem bei einem Zeilenumbruch in der Zelle, er übernimmt immer nur die letzte Farbe für die erste Zeile u die Zeile bleibt Standardschwarz...

Delphi-Quellcode:
var
  s : String;
  x : Integer;
begin
  s := StringGrid_Test.Cells[ACol, ARow];
  StringGrid_Test.Canvas.FillRect(Rect);
  DrawText(StringGrid_Test.canvas.Handle, PChar(s), Length(s), Rect, DT_left+DT_Vcenter);
with StringGrid_Test do
    if not (gdFixed in State) then
    begin
      if Pos('Meier',Cells[ACol,ARow]) > 0 then
      begin
        s := Copy(Cells[ACol,ARow],1,Pos('!',Cells[ACol,ARow])-1);
        Canvas.Font.Style := [fsBold];
        Canvas.Font.Color := clred;
        Canvas.TextOut(Rect.Left+1,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;

      if Pos('Müller',Cells[ACol,ARow]) > 0 then
      begin
        s := Copy(Cells[ACol,ARow],1,Pos('!',Cells[ACol,ARow])-1);
        Canvas.Font.Style := [fsBold];
        Canvas.Font.Color := clLime;
        Canvas.TextOut(Rect.Left+1,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;
end;
  Mit Zitat antworten Zitat