Witam
Jak wielu próbuję zmagać się z tabelą w stringgridzie. Znalazłęm na jakimś forum sposób na sformatowanie komórek/wierszy, wszystko byłoby fajnie, gdyby nie fakt, iż po sformatowaniu w gridzie pokazują się zarówno wartości przed jak i po operacji formatowania.
Jak sprawić, aby pojawiało się tylko to, co rysowane jest przez OnDrawCell??
KOD
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
inflaterect(rect,-2,-2);
if (ACol=1) then
DrawText(StringGrid1.canvas.Handle,PChar(StringGrid1.cells[Acol,Arow]),-1,rect,DT_Center)
else if (ACol=2) then
DrawText(StringGrid1.canvas.Handle,PChar(StringGrid1.cells[Acol,Arow]),-1,rect,DT_LEFT)
else
DrawText(StringGrid1.canvas.Handle,PChar(StringGrid1.cells[Acol,Arow]),-1,rect,DT_RIGHT);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
stringgrid1.Cells[0,2]:='1';
stringgrid1.Cells[1,2]:='1';
stringgrid1.Cells[2,2]:='1';
stringgrid1.Cells[3,2]:='1'
end;
end.