代码片断unit c_DataStru;interfaceuses
Classes, controls, dxEdLib, stdCtrls;type
TMySubItem =Class
Private
m_value: variant;
m_name : TComponentName;
m_type : Byte;
m_Control: TControl; Public
Constructor Create(f_name:string; f_type:Byte; _owner:TComponent; _parent:TWinControl);
DeStructor Destroy();
Procedure SetParent( _parent:TWinControl);
end;implementationConst
_Label : Byte =0;
_dxEdit : Byte =1;
_dxCheckEdit : Byte =2;
Procedure TMySubItem.SetParent( _parent:TWinControl);
begin
case m_type of
_Label ://报错
begin
(m_Control as TLabel).Parent:=_parent;
end;
_dxEdit :
begin
(m_Control as TdxEdit).Parent:=_parent;
end;
_dxCheckEdit :
begin
(m_Control as TdxCheckEdit).Parent:=_parent;
end;
end;
end;
Classes, controls, dxEdLib, stdCtrls;type
TMySubItem =Class
Private
m_value: variant;
m_name : TComponentName;
m_type : Byte;
m_Control: TControl; Public
Constructor Create(f_name:string; f_type:Byte; _owner:TComponent; _parent:TWinControl);
DeStructor Destroy();
Procedure SetParent( _parent:TWinControl);
end;implementationConst
_Label : Byte =0;
_dxEdit : Byte =1;
_dxCheckEdit : Byte =2;
Procedure TMySubItem.SetParent( _parent:TWinControl);
begin
case m_type of
_Label ://报错
begin
(m_Control as TLabel).Parent:=_parent;
end;
_dxEdit :
begin
(m_Control as TdxEdit).Parent:=_parent;
end;
_dxCheckEdit :
begin
(m_Control as TdxCheckEdit).Parent:=_parent;
end;
end;
end;
解决方案 »
- 我想Delphi调用一个BCB写的DLL
- 如何解决COM服务器重复创建的问题?
- 请问现在我有一个文件,我想把文件大小转换为十六进制.如何做?如1_2.png大小为41878,转换后的结果是9c65, 如果写这代码呢?
- 求助:Delphi下的排序问题(冒泡算法)
- 多线程序进行数据库操作的问题,大家帮忙啊。。。。。
- 我有一个数组,怎么样得到它的首地址
- 木子伟来了
- 创建新的DBGrid
- 怎么样实现一个日期的前后三大查询!急!!!!!!!
- 请问在把查询结果导出到Excel的时候自定义sheet的名称?
- 上论坛来的第一次放分:专家分突破1800....唉啊,想起4月份刚来的时候,穷苦不堪度日...向大家问好,满100结账。
- 一个关于打印的怪问题!
使用my_label,my_dxedit,my_cxcheckedit.
TMyType = (my_Label, my_dxedit, my_cxcheckedit); TMySubItem =Class
Private
m_value: variant;
m_name : TComponentName;
m_type : TMyType;
m_Control: TControl; Public
Constructor Create(f_name:string; f_type:Byte; _owner:TComponent; _parent:TWinControl);
DeStructor Destroy();
Procedure SetParent( _parent:TWinControl);
end;implementation
Classes, controls, dxEdLib, stdCtrls;type
TControltype = (_Label,_dxEdit,_dxCheckEdit);//自定义
TMySubItem =Class
Private
m_value: variant;
m_name : TComponentName;
m_Control: TControl;
m_type : TControltype; Public
Constructor Create(f_name:string; f_type:Byte; _owner:TComponent; _parent:TWinControl);
DeStructor Destroy();
Procedure SetParent( _parent:TWinControl);
end;
implementation
{
Const
_Label : Byte =0;
_dxEdit : Byte =1;
_dxCheckEdit : Byte =2;}
Procedure TMySubItem.SetParent( _parent:TWinControl);
begin
case m_type of
_Label :
begin
(m_Control as TLabel).Parent:=_parent;
end;
_dxEdit :
begin
(m_Control as TdxEdit).Parent:=_parent;
end;
_dxCheckEdit :
begin
(m_Control as TdxCheckEdit).Parent:=_parent;
end;
end;
end;Constructor TMySubItem.Create(f_name:string; f_type:byte; _owner:TComponent);
//构造时f_type定成byte m_type:=f_type 报错
//构造时f_type定成Tcontroltype m_type:=f_type 还是报错
begin
inherited Create();
m_type:= f_type;
m_Control.Parent:=_parent; case m_type of
_Label :
begin
m_Control:=(TLabel.Create(_owner) as TControl);
end;
_dxEdit :
begin
m_Control:=(TdxEdit.Create(_owner) as TControl);
end;
_dxCheckEdit :
begin
m_Control:=(TdxCheckEdit.Create(_owner) as TControl);
end;
end;
end;
c_DataStru._Label
c_DataStru._dxEdit
试试
Classes, controls, dxEdLib, stdCtrls;type
TControltype = (_Label,_dxEdit,_dxCheckEdit);//自定义
TMySubItem =Class
Private
m_value: variant;
m_name : TComponentName;
m_Control: TControl;
m_type : TControltype; Public
Constructor Create(f_name:string; f_type:Byte; _owner:TComponent; _parent:TWinControl);
DeStructor Destroy();
Procedure SetParent( _parent:TWinControl);
end;
implementation
{
Const
_Label : Byte =0;
_dxEdit : Byte =1;
_dxCheckEdit : Byte =2;}
Procedure TMySubItem.SetParent( _parent:TWinControl);
begin
case m_type of
_Label :
begin
(m_Control as TLabel).Parent:=_parent;
end;
_dxEdit :
begin
(m_Control as TdxEdit).Parent:=_parent;
end;
_dxCheckEdit :
begin
(m_Control as TdxCheckEdit).Parent:=_parent;
end;
end;
end;Constructor TMySubItem.Create(f_name:string; f_type:byte; _owner:TComponent);
//构造时f_type定成byte m_type:=f_type 报错
//构造时f_type定成Tcontroltype m_type:=f_type 还是报错
begin
inherited Create();
m_type:= f_type;
m_Control.Parent:=_parent; case m_type of
_Label :
begin
m_Control:=(TLabel.Create(_owner) as TControl);
end;
_dxEdit :
begin
m_Control:=(TdxEdit.Create(_owner) as TControl);
end;
_dxCheckEdit :
begin
m_Control:=(TdxCheckEdit.Create(_owner) as TControl);
end;
end;
end;
为什么错
是重载构造的问题哦
写类方法的时候上下声明有一致
具体你看看help就可以了
Constructor Create(f_name:string; f_type:TControltype ; _owner:TComponent; _parent:TWinControl);Constructor TMySubItem.Create(f_name:string; f_type:TControltype ; _owner:TComponent; _parent:TWinControl);
Classes, controls, dxEdLib, stdCtrls;type
TControltype = (ct_Label,ct_dxEdit,ct_dxCheckEdit);//自定义
TMySubItem =Class
Private
m_value: variant;
m_name : TComponentName;
m_Control: TControl;
m_type : TControltype; Public
Constructor Create(f_name:string; f_type:TControltype; _owner:TComponent; _parent:TWinControl);
DeStructor Destroy();
Procedure SetParent( _parent:TWinControl);
end;implementationProcedure TMySubItem.SetParent( _parent:TWinControl);
begin
case m_type of
ct_Label :
begin
(m_Control as TLabel).Parent:=_parent;
end;
ct_dxEdit :
begin
(m_Control as TdxEdit).Parent:=_parent;
end;
ct_dxCheckEdit :
begin
(m_Control as TdxCheckEdit).Parent:=_parent;
end;
end;
end;Constructor TMySubItem.Create(f_name:string; f_type:TControltype; _owner:TComponent;
_parent:TWinControl);
begin
inherited Create();
m_type:= f_type;
m_Control.Parent:=_parent; case m_type of
ct_Label :
begin
m_Control:=(TLabel.Create(_owner) as TControl);
end;
ct_dxEdit :
begin
m_Control:=(TdxEdit.Create(_owner) as TControl);
end;
ct_dxCheckEdit :
begin
m_Control:=(TdxCheckEdit.Create(_owner) as TControl);
end;
end;
end;
zswang(伴水)(伤心中),谢谢,我肯定加分给你
http://cn.ilike.lycosasia.com/program/book/index.html这里有很多~~
http://pcbook.godcn.net/download/default.asp?typeid=15这里也有不少~~