Autor Beitrag
moloch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Di 28.09.04 09:35 
Hallo leute,
wie kann ich am besten eine ganze Zeile in einem stringgrid färben?
also ich möchte jede 2. färben um genau zu sein. um die übersicht zu verbessrn.

mfg
moloch
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Di 28.09.04 09:40 
Im OnDrawCell. Beispiel aus einem meiner Projekte:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  with (Sender as TStringGrid) do
  begin
    if BP[ARow] then
    begin
      Canvas.Brush.Color:=clRed;
      Canvas.Font.Color:=clWhite;
      if Selection.Top = ARow then Canvas.Brush.Color:=clBlue;
    end else
    begin
      Canvas.Brush.Color:=clWhite;
      Canvas.Font.Color:=clBlack;
      if Selection.Top = ARow then
      begin
        Canvas.Brush.Color:=clHighlight;
        Canvas.Font.Color:=clWhite;
      end;
    end;
    if ACol = 1 then Canvas.Font.Style:=[fsBold] else Canvas.Font.Style:=[];
    Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+2,Cells[ACol,ARow]);
    Canvas.FrameRect(Rect);
  end;
end;

Hebt in einem dreispaltigen Grid Quelltext hervor (Breakpoints rot markiert, mittlere Spalte fett).

Probier maln bisschen rum. ;-)

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Di 28.09.04 09:51 
danke erstmal,
aber was meinst du mit BP???

mfg
moloch
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Di 28.09.04 09:52 
BP war bei mir ein Array of Boolean, das mir angezeigt hat, ob die jeweilige Zeile mit einem Breakpoint markiert ist. In deinem Fall könnte da Odd(ARow) stehen, da du ja jede zweite Zeile markieren willst.

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Di 28.09.04 10:14 
ok,das klappt auch super.danke.

mfg
moloch