1
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if acol=1 then
begin
settextalign(stringgrid1.Canvas.Handle,ta_right);
stringgrid1.Canvas.FillRect(Rect);
stringgrid1.Canvas.TextRect( Rect,rect.Right,rect.Top,StringGrid1.Cells[acol,arow]);
end;end;
2不行
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if acol=1 then
begin
settextalign(stringgrid1.Canvas.Handle,ta_right);
stringgrid1.Canvas.FillRect(Rect);
stringgrid1.Canvas.TextRect( Rect,rect.Right,rect.Top,StringGrid1.Cells[acol,arow]);
end;end;
2不行
if ACol>3 then
begin
SetTextAlign(StringGridDisplay.Canvas.Handle,TA_Right);
StringGridDisplay.Canvas.FillRect(Rect);
StringGridDisplay.Canvas.TextRect(Rect,Rect.Right,Rect.Top,StringGridDisPlay.Cells[acol,arow]);
end else //这里Top更改为Button,为什么就不能输出?
begin
SetTextAlign(StringGridDisplay.Canvas.Handle,TA_Left);
StringGridDisplay.Canvas.FillRect(Rect);
StringGridDisplay.Canvas.TextRect(Rect,rect.Left,rect.Top ,StringGridDisPlay.Cells[acol,arow]);
end;
Rect.Right-1,Rect.Top+2看起来比较舒服rect.button 是区域的底部;已经超出了rect的范围了
输出也看不到了