Hallo Miteinander
Ich versuche grad ein StringGrid zu testen, und bin erstaunt wieviel Quellcode das ding benötigt. Und da ich ein Newbie bin habe ich manches vielleicht total daneben Programmiert. Ich stelle meinen Quellcode hier rein und bitte euch mir verbesserungs Vorschläge mitzuteilen.
Wie kann ich die beschrifteten Zeilen auf der linken seite einfärben?
Danke im vorraus Niki
<PRE>
procedure TForm1.ColorGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var x : integer;
r : TRect;
outRect : TRect;
Text : String;
begin
begin
with ColorGrid.Canvas do
begin
case ARow mod 14 of
0: Brush.Color := clAqua;
1: Brush.Color := currZV.currEnterColor;
2: Brush.Color := clWindow;
3: Brush.Color := currZV.currEnterColor;
4: Brush.Color := clWindow;
5: Brush.Color := currZV.currEnterColor;
6: Brush.Color := clWindow;
7: Brush.Color := currZV.currEnterColor;
8: Brush.Color := clWindow;
9: Brush.Color := currZV.currEnterColor;
10: Brush.Color := clWindow;
11: Brush.Color := currZV.currEnterColor;
12: Brush.Color := clWindow;
13: Brush.Color := currZV.currEnterColor;
14: Brush.Color := clWindow;
end;
end;
if {(ColorGrid.Selection.Left = ACol) and} (ColorGrid.Selection.Top = ARow) then
begin
Font.Color := Brush.Color xor 65535;
if arow = 0 then
with ColorGrid.Canvas do
begin{5}
for x:= 0 to ColorGrid.ColCount-1 do
begin{6}
font.Color := clBlack;
end;{6}
end;{5}
end;{4}
ColorGrid.Canvas.FillRect(Rect);
DrawText(ColorGrid.Canvas.Handle,
PChar(ColorGrid.Cells[ACol, ARow]),
length(ColorGrid.Cells[ACol, ARow]),
Rect, DT_WordBreak)
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
currZV.currEnterColor := clYellow;
currZV.currExitColor := clWhite;
currZV.currFehlerColor := clRed;
with ColorGrid do
begin
RowCount := 14;
ColCount := 5;
ColWidths[0] := 60;
ColWidths[1] := 75;
ColWidths[2] := 75;
ColWidths[3] := 75;
ColWidths[4] := 75;
RowHeights[0] := 35;
RowHeights[1] := 18;
RowHeights[2] := 18;
RowHeights[3] := 18;
RowHeights[4] := 18;
RowHeights[5] := 18;
RowHeights[6] := 18;
RowHeights[7] := 18;
RowHeights[8] := 18;
RowHeights[9] := 18;
RowHeights[10] := 18;
RowHeights[11] := 18;
RowHeights[12] := 18;
RowHeights[13] := 18;
Cells[0,1] := 'Summe';
Cells[0,2] := 'Jänner';
Cells[0,3] := 'Februar';
Cells[0,4] := 'März';
Cells[0,5] := 'April';
Cells[0,6] := 'Mai';
Cells[0,7] := 'Juni';
Cells[0,8] := 'Juli';
Cells[0,9] := 'August';
Cells[0,10] := 'September';
Cells[0,11] := 'Oktober';
Cells[0,12] := 'November';
Cells[0,13] := 'Dezember';
Cells[1,0] := 'Umsatz in €';
Cells[2,0] := 'Roherlöse in €';
Cells[3,0] := 'Stückum satz';
Cells[4,0] := 'Gewichtsumme in kg';
end;
end;
procedure ColorGridAlignment(Grid: TStringGrid; Rect: TRect; ACol, ARow: Integer; Alignment : TAlignment; Linebreak: Boolean);
var TextOut : String;
const SelectedColor = Clblue;
begin
Grid.Canvas.FillRect(Rect);
TextOut := Grid.Cells[ACol,ARow];
if Linebreak = false then
begin
if Alignment = taRightJustify then
DrawText(Grid.Canvas.Handle, PChar(TextOut),
StrLen(PChar(TextOut)), Rect,DT_Right);
end;
end;
procedure TForm1.ColorGridSelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean);
begin
ShowMessa
Ich versuche grad ein StringGrid zu testen, und bin erstaunt wieviel Quellcode das ding benötigt. Und da ich ein Newbie bin habe ich manches vielleicht total daneben Programmiert. Ich stelle meinen Quellcode hier rein und bitte euch mir verbesserungs Vorschläge mitzuteilen.
Wie kann ich die beschrifteten Zeilen auf der linken seite einfärben?
Danke im vorraus Niki
<PRE>
procedure TForm1.ColorGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var x : integer;
r : TRect;
outRect : TRect;
Text : String;
begin
begin
with ColorGrid.Canvas do
begin
case ARow mod 14 of
0: Brush.Color := clAqua;
1: Brush.Color := currZV.currEnterColor;
2: Brush.Color := clWindow;
3: Brush.Color := currZV.currEnterColor;
4: Brush.Color := clWindow;
5: Brush.Color := currZV.currEnterColor;
6: Brush.Color := clWindow;
7: Brush.Color := currZV.currEnterColor;
8: Brush.Color := clWindow;
9: Brush.Color := currZV.currEnterColor;
10: Brush.Color := clWindow;
11: Brush.Color := currZV.currEnterColor;
12: Brush.Color := clWindow;
13: Brush.Color := currZV.currEnterColor;
14: Brush.Color := clWindow;
end;
end;
if {(ColorGrid.Selection.Left = ACol) and} (ColorGrid.Selection.Top = ARow) then
begin
Font.Color := Brush.Color xor 65535;
if arow = 0 then
with ColorGrid.Canvas do
begin{5}
for x:= 0 to ColorGrid.ColCount-1 do
begin{6}
font.Color := clBlack;
end;{6}
end;{5}
end;{4}
ColorGrid.Canvas.FillRect(Rect);
DrawText(ColorGrid.Canvas.Handle,
PChar(ColorGrid.Cells[ACol, ARow]),
length(ColorGrid.Cells[ACol, ARow]),
Rect, DT_WordBreak)
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
currZV.currEnterColor := clYellow;
currZV.currExitColor := clWhite;
currZV.currFehlerColor := clRed;
with ColorGrid do
begin
RowCount := 14;
ColCount := 5;
ColWidths[0] := 60;
ColWidths[1] := 75;
ColWidths[2] := 75;
ColWidths[3] := 75;
ColWidths[4] := 75;
RowHeights[0] := 35;
RowHeights[1] := 18;
RowHeights[2] := 18;
RowHeights[3] := 18;
RowHeights[4] := 18;
RowHeights[5] := 18;
RowHeights[6] := 18;
RowHeights[7] := 18;
RowHeights[8] := 18;
RowHeights[9] := 18;
RowHeights[10] := 18;
RowHeights[11] := 18;
RowHeights[12] := 18;
RowHeights[13] := 18;
Cells[0,1] := 'Summe';
Cells[0,2] := 'Jänner';
Cells[0,3] := 'Februar';
Cells[0,4] := 'März';
Cells[0,5] := 'April';
Cells[0,6] := 'Mai';
Cells[0,7] := 'Juni';
Cells[0,8] := 'Juli';
Cells[0,9] := 'August';
Cells[0,10] := 'September';
Cells[0,11] := 'Oktober';
Cells[0,12] := 'November';
Cells[0,13] := 'Dezember';
Cells[1,0] := 'Umsatz in €';
Cells[2,0] := 'Roherlöse in €';
Cells[3,0] := 'Stückum satz';
Cells[4,0] := 'Gewichtsumme in kg';
end;
end;
procedure ColorGridAlignment(Grid: TStringGrid; Rect: TRect; ACol, ARow: Integer; Alignment : TAlignment; Linebreak: Boolean);
var TextOut : String;
const SelectedColor = Clblue;
begin
Grid.Canvas.FillRect(Rect);
TextOut := Grid.Cells[ACol,ARow];
if Linebreak = false then
begin
if Alignment = taRightJustify then
DrawText(Grid.Canvas.Handle, PChar(TextOut),
StrLen(PChar(TextOut)), Rect,DT_Right);
end;
end;
procedure TForm1.ColorGridSelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean);
begin
ShowMessa
Comment