设动态创建的Button name为'tmpBtn'
解决方案 »
- delphi7+access2000做个记录软件,数据表字段名用汉字有影响吗?
- 具备小计、合计,有点难度的特定格式查询
- 如何实现某一窗体运行后能保持处于其他任何应用程序之前???
- 请问怎么把图片作为资源加入到资源文件中
- delphi帮助文件问题
- 画布上输出文本的问题,帮忙解决!
- 如何用挂钩函数作屏幕取词
- 简单问题-怎样做一个返回一个StringList型(TStirngs)的函数?在线等待!!!
- 求助!!!!interbase 5 数据库损坏,应如何修复?或用什么工具修复?谢谢!
- 请问:哪里有fastreport的使用教程,它自带的实在是看不懂。或者给个例子也行
- 请问:在Deiphi7中怎样加入Deiphi6中的Internet控件页?
- C/S结构的准确定义是什么?
tmpBtn.Enabled := true;
var
tmpButton: TButton;
TC: TComponent;
begin
TC:= FindComponent('tmpBtn');
if TC = nil then
begin
tmpButton:= TButton.Create(self);
with tmpButton do
begin
Parent:= self;
Name := 'btn_tmp';
Height:= 25;
Width := 75;
Left := W-85;
Top := H-35;
TabOrder := 0;
Caption:= '取 消';
OnClick:= tmpBtnClick;
end;
end;
end;
x: tbutton;
begin
x := tbutton.Create(application);
x.Parent := self;
x.Name := 'tmpBtn';
if assigned(x) then
x.Enabled := False;
end;
procedure TForm1.Button1Click(Sender: TObject);//创建
var
NewButton: TButton;
begin
NewButton := TButton.Create(Form1);
NewButton.Parent := Form1;
NewButton.Caption := '123456';
NewButton.Enabled := true;
end;procedure TForm1.Button2Click(Sender: TObject);//设置
var
i:integer;
begin
For i:=0 to Self.ComponentCount-1 do
begin
if TButton(Self.Components[i]).Caption = '123456' then
TButton(Self.Components[i]).Enabled := false;//重新设置
end;
end;------------
如果创建的时候要设置的话,直接设置就可以了,我试过,可以的
procedure TForm1.Button1Click(Sender: TObject);
var
NewButton: TButton;
begin
NewButton := TButton.Create(Form1);
NewButton.Parent := Form1;
NewButton.Caption := '123456';
NewButton.Enabled := true;//这里
end;
TButton(MainForm.FindComponent('123456')).Enable:= True;