有两个问题,急!(200分)

  • 主题发起人 主题发起人 泥瓦匠
  • 开始时间 开始时间

泥瓦匠

Unregistered / Unconfirmed
GUEST, unregistred user!
有两个问题,急!
1.在DBGRID中画金额线,听说RID的ONDRAW中做就行,我不会,帮我做个例子。OK?
2.我要把一个COMBOBOX绑定到GRID中,
procedure TFrmMain.DBGridEh1CellClick(Column: TColumnEh);
var
re:TRect;
begin
re:=DBGridEh1.CellRect(DBGridEh1.col,DBGridEh1.row);
WWPyDbComBo1.Top:=DBGridEh1.top+re.Top;
WWPyDbComBo1.left:=DBGridEh1.left+Re.Left;
WWPyDbComBo1.Width:=re.Left-re.Right;
WWPyDbComBo1.Height:=re.Top-re.Bottom;
WWPyDbComBo1.show;
不行,怎么样做才可以.

谢谢帮助!
 
第二个问题已解决
 
在ondrawcolumncell事件中
Dbgrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
怎样的金额线,举个例子
 
泥瓦匠,给你一份我做的控件,试试看.
 
1.可以在dbgrid上放置QRShape1,QRShape11.width=1;还可以设置颜色,我做的帐务凭证给
你发过去看看.不知道你的email.
 
我找到了一段代码,如下。
procedure TwjCustomDBGrid.DrawLine(const Rect: TRect; field:Tfield;isHJ: Boolean);
var w:Byte;
b:double;
s,s1:string;
oldcolor:Tcolor;
oldpencolor:Tcolor;
redcolor:boolean;
dec,len,sumlen,n,lettercount: integer;
oldpenwidth:integer;
begin
with dbgrid1 do
begin
oldpenwidth:=canvas.Pen.width;
oldcolor:=Canvas.font.color;
oldpencolor:=canvas.pen.color;
redcolor:=False;
if ishj then
begin
b:=Tfloatfield(field).value;
if b<0 then
begin
b:=abs(b);
redcolor:=true;
oldcolor:=Canvas.font.color;
Canvas.font.color:=clred;
end;
s:=format('%8.2f',);
if (b=0) {and FForpingzheng} then s:='';
end else s:='';
len:=length(s);
dec:=2;
S1:=copy(s,1,len-dec-1)+copy(s,len-dec+1,dec);
lettercount:=length(s)-1;{去小数点}
w:=Canvas.TextWidth('0')+2;
// w:=8;{单线宽度}
sumlen:=Rect.Right-Rect.left;

{***对线画数}
n:=0;
while sumlen>=w do
begin
sumlen:=sumlen-w;
n:=n+1;
if n=2 then
begin
canvas.Pen.Color:=clRed;
Canvas.Pen.Width:=1;
end else
if (n-2) mod 3=0 then
begin
Canvas.Pen.Color:=clTeal;
canvas.Pen.Width:=2;
end else
begin
Canvas.Pen.Color:=clTeal;
canvas.Pen.Width:=1;
end;
if lettercount-n+1>=1 then
Canvas.Textout(Rect.Right-n*w+1,Rect.Top+1,s1[lettercount-n+1]);
canvas.Moveto(Rect.Right-n*w,Rect.Top+1);
canvas.Lineto(Rect.Right-n*w,Rect.Bottom-1);
end;
if redcolor then canvas.font.color:=oldcolor;
canvas.pen.color:=oldpencolor;
canvas.pen.width:=oldpenwidth;
end;
end;
 
多人接受答案了。
 
后退
顶部