DBGrid 控件 怎样嵌套 别的控件!!!!(30分)

  • 主题发起人 apple058
  • 开始时间
A

apple058

Unregistered / Unconfirmed
GUEST, unregistred user!
各位高手:
请问我怎样在 DBGrid 的网格中嵌套 别的控件 譬如: CheckBox , Edit, Radiobox 等等
譬如:pB 就自带有这功能, Delphi 怎样实现呢?
 
不可能吧 ! 这么经典的问题没有人回答我!!!!
 
放一个控件在上面,设置其VISIBLE为FALSE,然后dbgrid的onDrawColumnCell事件中写如下
procedure TDrawingDistributeForm.DbgDistributeDrawColumnCell(
Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if (gdselected in state) and (column.Index =2) then //(column.Field.FieldName='fdept_no')
begin
cbdept.SetBounds(rect.Left+DbgDistribute.Left+1,
rect.Top+DbgDistribute.Top+1,rect.Right-rect.Left+4,rect.Bottom-rect.Top) ;
cbdept.Text:=DbgDistribute.Fields[2].AsString;
cbdept.visible:=true;
end
else
cbdept.visible:=false;
end;
本例为cbdept控件在DbgDistribute的第三列显示
 
用DBGridEh或者dxDbGrid吧,都带有源码,向自己玩的话也可以研究研究。
 
顶部