2 linier i TStringGrid
Hej eksperterJeg skal have to linier i hver colonne i TStringGrid. Jeg har set at det kan lade sig gøre jvf. http://www.eksperten.dk/spm/400670
Men jeg kan simpelthen ikke overskue min DrawCell mere,,, Kan i hjælpe mig?
procedure TOpgaveMainForm.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
OpgNr, i, TempI: Integer;
opgType,s1,s2,ansat,beskrivelse: string;
BgColor, FColor: TColor;
R : TRect;
Opgave: boolean;
begin
with (Sender as TStringGrid) do begin
if (ACol = 0) or (ARow = 0) then
Canvas.Brush.Color := clBtnFace
else
If Cells[ACol,ARow] <> '' Then
begin
// Først skal der testes om det er fravær eller en opgave.
s1 := Cells[ACol,ARow];
s2 := copy(s1,0,1);
Opgave := true;
try
TempI := StrtoInt(s2);
except
on E:EConvertError do
begin
Opgave := false;
end;
end;
if not Opgave
then
begin
//Så er det fravær
beskrivelse := s1;
OpgKarForm.fravaerT.First;
while not OpgKarForm.fravaerT.EOF do
begin
if OpgKarForm.fravaerT.FieldByName('Beskrivelse').text <> beskrivelse
then OpgKarForm.fravaerT.next
else
begin
OpgType := OpgKarForm.fravaerT.FieldByName('type').text;
OpgKarForm.FraTypT.First;
while not OpgKArForm.fratypT.Eof do
begin
if OpgKarForm.fraTypT.FieldByName('Type Navn').text = OpgType
then
begin
BGColor := StringToColor
(OpgKarForm.FraTypt.FieldByName('baggrunds farve').text);
FColor := StringToColor
(OpgKarForm.FraTypT.FieldByName('Tekst farve').text);
//showmessage(OpgKArForm.FraTypT.FieldByName('baggrunds farve').text);
OpgKarForm.FraTypT.last;
end
else OpgKArForm.FraTypT.Next;
end;
end;
OpgKarForm.fravaerT.Last;
end;
end
else
begin
//så er det en opgave
OpgNr := FindKundeNr(Cells[ACol,ARow]);
OpgKarForm.PlacOpgT.first;
while not OpgKarForm.PlacOpgT.EOF do
begin
if OpgKarForm.PlacOpgT.FieldByName('Opgave Nr.').asInteger <> opgNr
then OpgKarForm.placOpgT.Next
else
begin
opgType := OpgKarForm.PlacOpgT['type'];
OpgKarForm.TypeTabel.first;
while not OpgKarForm.TypeTabel.EOF do
begin
if OpgKarForm.TypeTabel.fieldByName('Typenavn').text = opgType
then
begin
//showmessage('lort');
BGColor := StringToColor
(OpgKarForm.TypeTabel.fieldByName('baggrunds farve').text);
FColor := StringToColor
(OpgKarForm.TypeTabel.fieldByName('Tekst farve').text);
OpgKarForm.TypeTabel.last;
end
else OpgKarForm.TypeTabel.next;
end;
OpgKarForm.PlacOpgT.Last;
end;
end;
end;
//showmessage(ColorToString(BGColor));
Canvas.Brush.color := BGColor;
Canvas.Font.Color := FColor;
Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, cells[acol, arow]);
Canvas.FrameRect(Rect);
if (TidGrid.row = Arow) and (tidGrid.col = Acol) then
begin
TidGrid.Canvas.Pen.Color := clBlack;
TidGrid.Canvas.Pen.Width := 5;
TidGrid.Canvas.DrawFocusRect(Rect);
R := Rect;
dec(R.Left,2);
dec(R.Top,2);
Inc(R.Right,3);
Inc(R.Bottom,3);
Canvas.Brush.color := clBlack;
canvas.FrameRect(R);
end;
end;
end;
end;
