重画 procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin with Sender as TStringGrid do if (arow=0) then begin canvas.TextOut(Rect.Left+2,Rect.Top+2,'测'); canvas.TextOut(Rect.Left+2,Rect.Top+14,'试'); end; end;
//demo //初始formcreate事件里写 StringGrid1.RowHeights[0]:=60; StringGrid1.Cells[0,0]:='编'+#13+'程'+#13+'论'+#13+'坛'; //在stringgriddrawcell事件里写 procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin if ARow=0 then begin StringGrid1.Canvas.FillRect(Rect); DrawText(StringGrid1.Canvas.Handle, pchar(StringGrid1.Cells[ACol,ARow]), length(StringGrid1.Cells[ACol,ARow]), Rect,DT_CENTER); end; end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin with Sender as TStringGrid do
if (arow=0) then
begin
canvas.TextOut(Rect.Left+2,Rect.Top+2,'测');
canvas.TextOut(Rect.Left+2,Rect.Top+14,'试'); end;
end;
//初始formcreate事件里写
StringGrid1.RowHeights[0]:=60;
StringGrid1.Cells[0,0]:='编'+#13+'程'+#13+'论'+#13+'坛';
//在stringgriddrawcell事件里写
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if ARow=0 then
begin
StringGrid1.Canvas.FillRect(Rect);
DrawText(StringGrid1.Canvas.Handle,
pchar(StringGrid1.Cells[ACol,ARow]),
length(StringGrid1.Cells[ACol,ARow]),
Rect,DT_CENTER);
end;
end;