sguerra
asked on
Colored StringGrid
Hi
I need for my application a stringgrid with alternative colors in each row, but my grid needs to be in a goAlwaysShowEditor := True codition. But when a cell is being edited turns white with black text. I got something like this:
procedure TForm1.StringGrid1DrawCell (Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if (gdFocused in State) then begin
if (Arow mod 2 = 1) then begin
StringGrid1.Canvas.Brush.C olor := clYellow;
StringGrid1.Canvas.Font.Co lor := clMaroon;
end
else begin
StringGrid1.Canvas.Brush.C olor := clWhite;
StringGrid1.Canvas.Font.Co lor := clBlack;
end;
end
else
if (Arow mod 2 = 1) then begin
StringGrid1.Canvas.Brush.C olor := clYellow;
StringGrid1.Canvas.Font.Co lor := clMaroon;
end
else begin
StringGrid1.Canvas.Brush.C olor := clWhite;
StringGrid1.Canvas.Font.Co lor := clBlack;
end;
If (ARow>0) then
begin
StringGrid1.canvas.fillRec t(Rect);
StringGrid1.canvas.TextOut (Rect.Left ,Rect.Top, StringGrid 1.Cells[AC ol,ARow]);
end;
end;
I need that the cell that is being edited do not change color. Please help, I am looking for this solution on-line for 2 days now and there is only the same answer again and again State = [gdFocused], but that does not helps.
I need for my application a stringgrid with alternative colors in each row, but my grid needs to be in a goAlwaysShowEditor := True codition. But when a cell is being edited turns white with black text. I got something like this:
procedure TForm1.StringGrid1DrawCell
Rect: TRect; State: TGridDrawState);
begin
if (gdFocused in State) then begin
if (Arow mod 2 = 1) then begin
StringGrid1.Canvas.Brush.C
StringGrid1.Canvas.Font.Co
end
else begin
StringGrid1.Canvas.Brush.C
StringGrid1.Canvas.Font.Co
end;
end
else
if (Arow mod 2 = 1) then begin
StringGrid1.Canvas.Brush.C
StringGrid1.Canvas.Font.Co
end
else begin
StringGrid1.Canvas.Brush.C
StringGrid1.Canvas.Font.Co
end;
If (ARow>0) then
begin
StringGrid1.canvas.fillRec
StringGrid1.canvas.TextOut
end;
end;
I need that the cell that is being edited do not change color. Please help, I am looking for this solution on-line for 2 days now and there is only the same answer again and again State = [gdFocused], but that does not helps.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks mocarts, it worked perfectly
don't forget to accept answer ;)
wbr, mo.
wbr, mo.
procedure TForm1.StringGrid1GetEditT
ARow: Integer; var Value: String);
begin
if assigned(TMyStringGrid(Str
with TMyInplaceEdit(TMyStringGr
Color := GetBrushColor(ARow);
Font.Color := GetPenColor(ARow);
end;
end;
wbr, mo.