Y
yj8888
Unregistered / Unconfirmed
GUEST, unregistred user!
请大家帮忙!
DbGrid中的某个值,比如价格输入的时候,应该为12.89,
但我故意输入错误的数值12..89,系统提示:
'12..89' is not a valid floating point value for field Price22
我不想把这些信息显示给客户,不雅观.
请问该怎么帮?
其它的数据感知组件也都是这样的.是不是只有用stringgrid再自己控制.
用stringgrid工作量实在太大了.
-------------------------------------------------------------
TdxDBGrid如何改变某行(或任意数据如Cell[Acol,ARow])的字的颜色和背景.
dxDBGrid1: TdxDBGrid;
procedure Tfmbaseinfo56.dxDBGrid1CustomDraw(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
begin
inherited;
if ADODataSet2.FieldByName('Num22').AsInteger>200 then
AFont.Color := clRed;
end;
//上面的运行起来不行.
要类似与StringGrid1这样的效果
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
dx, dy : byte;
begin
if (acol = 2) and (arow = 2) then
with stringgrid1 do
begin
canvas.Brush.color := clYellow;
canvas.FillRect(Rect);
canvas.font.color := clblue;
canvas.font.name := '宋体';
dx := 2; //调整此值,控制字在网格中显示的水平位置
dy := 2; //调整此值,控制字在网格中显示的垂直位置
canvas.TextOut(rect.left + dx, rect.top + dy, cells[acol, arow]);
end;
end;
-------------------------------
另:如何 掩码 StringGrid1: TStringGrid
procedure TForm1.Button1Click(Sender: TObject);
var
I, J, K : Integer;
begin
K := 0;
with StringGrid1 do
for I := 0 to ColCount - 1 do
for J:= 0 to RowCount - 1 do
begin
Cells[I,J] := IntToStr(K);
//Cells[I,J] := FormatFloat('#0.00',K); 不想这样写入。
K := K + 1;
end;
end;
不想把数据掩码后,再写入,就是说想在数据写入前或后,StringGrid1再掩码都可以。
就好象DbGrid的DisplayFormat:='#0.00'属性那样也可以。
DbGrid中的某个值,比如价格输入的时候,应该为12.89,
但我故意输入错误的数值12..89,系统提示:
'12..89' is not a valid floating point value for field Price22
我不想把这些信息显示给客户,不雅观.
请问该怎么帮?
其它的数据感知组件也都是这样的.是不是只有用stringgrid再自己控制.
用stringgrid工作量实在太大了.
-------------------------------------------------------------
TdxDBGrid如何改变某行(或任意数据如Cell[Acol,ARow])的字的颜色和背景.
dxDBGrid1: TdxDBGrid;
procedure Tfmbaseinfo56.dxDBGrid1CustomDraw(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
begin
inherited;
if ADODataSet2.FieldByName('Num22').AsInteger>200 then
AFont.Color := clRed;
end;
//上面的运行起来不行.
要类似与StringGrid1这样的效果
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
dx, dy : byte;
begin
if (acol = 2) and (arow = 2) then
with stringgrid1 do
begin
canvas.Brush.color := clYellow;
canvas.FillRect(Rect);
canvas.font.color := clblue;
canvas.font.name := '宋体';
dx := 2; //调整此值,控制字在网格中显示的水平位置
dy := 2; //调整此值,控制字在网格中显示的垂直位置
canvas.TextOut(rect.left + dx, rect.top + dy, cells[acol, arow]);
end;
end;
-------------------------------
另:如何 掩码 StringGrid1: TStringGrid
procedure TForm1.Button1Click(Sender: TObject);
var
I, J, K : Integer;
begin
K := 0;
with StringGrid1 do
for I := 0 to ColCount - 1 do
for J:= 0 to RowCount - 1 do
begin
Cells[I,J] := IntToStr(K);
//Cells[I,J] := FormatFloat('#0.00',K); 不想这样写入。
K := K + 1;
end;
end;
不想把数据掩码后,再写入,就是说想在数据写入前或后,StringGrid1再掩码都可以。
就好象DbGrid的DisplayFormat:='#0.00'属性那样也可以。