当点击一个Button后,出现一个窗体,在窗体中怎么得到此Button的Caption, Name? 此Button是动态产生的!谢谢!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://expert.csdn.net/Expert/topic/2898/2898828.xml?temp=.5325434功能类似,参照其试一试 to leeky():此Button是动态产生的!所以其属性都是动态的,怎么赋值给变量? 在DFW里找到:在Button的事件里的话:(Sender as TButton).Caption;(Sender as TButton).Name // Unit1中的代码type TForm1 = class(TForm) private { Private declarations } public { Public declarations } procedure ButtonClick(Sender: TObject); end;procedure TForm1.ButtonClick(Sender: TObject); // 动态按钮的OnClick事件begin Form2.ShowForm(Sender);end;procedure TForm1.Button6Click(Sender: TObject); // 通过这个过程来动态创建按钮var Button: TButton;begin Button := TButton.Create(Self); Button.Parent := Self; Button.Caption := '动态创建按钮'; Button.OnClick := ButtonClick; // 定义OnClick事件 // Button.Freeend;--------------------------------------------// Unit2中的代码type TForm2 = class(TForm) private { Private declarations } public { Public declarations } procedure ShowForm(Sender: TObject); end;var Form2: TForm2;implementation{$R *.dfm}{ TForm2 }procedure TForm2.ShowForm(Sender: TObject);begin if Sender is TButton then // 使用TButton时候需要引用 StdCtrls 单元 ShowMessage(TButton(Sender).Caption); Show;end; procedure TForm2.ShowForm(Sender: TObject);begin if Sender is TButton then // 使用TButton时候需要引用 StdCtrls 单元 begin ShowMessage(TButton(Sender).Caption); // 得到 Catpion ShowMessage(TButton(Sender).Name); // 得到 Name end; Show;end;// Unit1 对应 Form1; Unit2 对应 Form2。 【高分】 基础没打好,问个记录排序的问题 ADOTable1.GetFieldNames()错误 关于读取图片的问题! 第一次使用FASTREPORT,发现程序启动时很慢,不知各位是怎样解决的 散分啦——请问关于TOleContainer一个过程的问题 100分!!!!!征集解决方法!急!急!!急!!! 在windows NT的域服务器上为什么不能装informix数据库? dbgird某行被选中,点击修改在另一个窗体得到该行的值 发 “分”! 如何在TreeView,ListView中添加背景图片,好象有点难度? ★★★ WMV文件有什么好的方法加密! ★★★ 哪种方法更有效率?
功能类似,参照其试一试
在DFW里找到:在Button的事件里的话:
(Sender as TButton).Caption;
(Sender as TButton).Name
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure ButtonClick(Sender: TObject);
end;procedure TForm1.ButtonClick(Sender: TObject); // 动态按钮的OnClick事件
begin
Form2.ShowForm(Sender);
end;procedure TForm1.Button6Click(Sender: TObject); // 通过这个过程来动态创建按钮
var
Button: TButton;
begin
Button := TButton.Create(Self);
Button.Parent := Self;
Button.Caption := '动态创建按钮';
Button.OnClick := ButtonClick; // 定义OnClick事件
// Button.Free
end;--------------------------------------------
// Unit2中的代码type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure ShowForm(Sender: TObject);
end;var
Form2: TForm2;implementation{$R *.dfm}{ TForm2 }procedure TForm2.ShowForm(Sender: TObject);
begin
if Sender is TButton then // 使用TButton时候需要引用 StdCtrls 单元
ShowMessage(TButton(Sender).Caption);
Show;
end;
begin
if Sender is TButton then // 使用TButton时候需要引用 StdCtrls 单元
begin
ShowMessage(TButton(Sender).Caption); // 得到 Catpion
ShowMessage(TButton(Sender).Name); // 得到 Name
end;
Show;
end;// Unit1 对应 Form1; Unit2 对应 Form2。