A
a_ping
Unregistered / Unconfirmed
GUEST, unregistred user!
1。我的StringGrid一共有四列,其第三第四列需将数据靠右,我通过下面的代码实现了
procedure TActiveFormX.DataGridDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
vCol, vRow : LongInt;
begin
vCol := ACol; vRow := ARow;
with Sender as TStringGrid, Canvas do
if ((vCol = 2) or (vCol = 3)) and (vRow > 0) then
begin ///对于第2列设置为右对齐
SetTextAlign(Handle, TA_RIGHT);
FillRect(Rect);
TextRect(Rect, Rect.RIGHT-2, Rect.Top+2, Cells[vCol, vRow]);
end;
end;
但现在问题是我的前面两列的数据都显示不出来,要点一下才能看见,怎么回事?
2。如果在StringGrid里某格输入一个负数,怎么让这个数字显示成红色?
procedure TActiveFormX.DataGridDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
vCol, vRow : LongInt;
begin
vCol := ACol; vRow := ARow;
with Sender as TStringGrid, Canvas do
if ((vCol = 2) or (vCol = 3)) and (vRow > 0) then
begin ///对于第2列设置为右对齐
SetTextAlign(Handle, TA_RIGHT);
FillRect(Rect);
TextRect(Rect, Rect.RIGHT-2, Rect.Top+2, Cells[vCol, vRow]);
end;
end;
但现在问题是我的前面两列的数据都显示不出来,要点一下才能看见,怎么回事?
2。如果在StringGrid里某格输入一个负数,怎么让这个数字显示成红色?