看下列的,,,,
procedure TFMAIN.PLANGRIDDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
showme,st,tt:string;
RectWidth, StartHere : integer;
listn,lists:integer;
a,b,c,d,e,f,g,h,i,n,GG:integer;
// qexy,qedy,cexy,cedy,tco:tcolor;//缺额小于 缺额大于 超额小于 超额大于
begin
if (Sender IS TStringGrid) then
with TStringGrid(Sender) do
BEGIN
ShowMe := Cells[ACol, ARow];
IF SHOWME<>'' THEN
begin
VAL(SHOWME,GG,N);
if n=0 then
begin
LISTN:=FSETUP.mainstr.Count;
ST:=CELLS[0,AROW];
IF ST<>'' THEN
BEGIN
LISTS:=0;
WHILE LISTS<LISTN DO
BEGIN
tt:=trim(copy(fsetup.mainstr.Strings[lists] ,length('编号为: '),length(fsetup.mainstr.Strings[lists])-length('编号为: ')+1));
IF ST=TT THEN
BEGIN
ST:=FSETUP.TreeView1.Items[0].ITEM[LISTS].ITEM[2].TEXT;
ST:=COPY(ST,12,LENGTH(ST)-11);
VAL(ST,A,B); //A为限额数量
ST:=FSETUP.TreeView1.Items[0].ITEM[LISTS].ITEM[3].TEXT;
I:=INSTRL(ST,'低');
ST:=COPY(ST,12,I-12);
VAL(ST,C,D);//C为不足中的分隔线
ST:=FSETUP.TreeView1.Items[0].ITEM[LISTS].ITEM[4].TEXT;
I:=INSTRL(ST,'低');
ST:=COPY(ST,12,I-12);
VAL(ST,E,F);//e为超过中的分隔线
ST:=CELLS[2,AROW];
VAL(ST,G,H);//G是剩余数量
//GG是要填入的数字
IF (B=0) AND (D=0) AND (F=0) THEN
BEGIN
if (GG<=C) and (ACOL=4) then
begin
if (h=0) and ((gg+g)=a) then
begin
canvas.brush.Color:=cLYELLOW;
canvas.Font.Color:=clred;
canvas.FillRect(rECT);
canvas.TextRect(rect,0,0,inttostr(i));
end;
end;
if (GG>=C) and (ACOL=4) then
begin
if (h=0) and ((gg+g)=a) then
begin
canvas.brush.Color:=clRED;
canvas.Font.Color:=clYELLOW;
canvas.FillRect(rect);
canvas.TextRect(rect,0,0,inttostr(i));
end;
end;
if (GG<=E) AND (ACOL=5) then
begin
if (h=0) and ((gg+a)=g) then
begin
canvas.brush.Color:=clYELLOW;
CANVAS.Font.Color:=CLRED;
canvas.FillRect(rect);
canvas.TextRect(rect,0,0,inttostr(i));
end;
end;
if (GG>=E) and (ACOL=5) then
begin
if (h=0) and ((gg+a)=g) then
begin
canvas.brush.Color:=CLGREEN;
CANVAS.Font.Color:=CLWHITE;
canvas.FillRect(rect);
canvas.TextRect(rect,0,0,inttostr(i));
end;
end;
END//END OF B=0 AND D=0 AND F=0
ELSE
BEGIN
//MESSAGEBOX(0,PCHAR('剩余数量一格所填不是数字,请改正!'),PCHAR('发现错误'),MB_OK);
END;//END OF ELSE BEGIN
END;//END OF IF ST=TT
INC(LISTS);
END;//END OF WHILE LISTS<LISTN
END;//END OF IF ST<>''
end;//end of n=0
end;//end of showme<>''
end;//end of with sender
if (sender is tstringgrid) then
with tstringgrid(sender) do
begin
ShowMe := Cells[ACol, ARow];
RectWidth := Rect.Right - Rect.Left;
if arow=0 then
begin
starthere:=rect.Left+(rectwidth-canvas.textwidth(cells[acol,arow]))div 2;
end
else
begin
StartHere := Rect.Left -2+
((RectWidth - Canvas.TextWidth(Cells[ACol, ARow]) ) );
end;
Canvas.FillRect(Rect);
Canvas.TextOut(StartHere, Rect.Top+2, Cells[ACol,ARow]);
end;//end if if sender is tstringgrid
end;