[英]Delphi 10.2 - Return names of clicked TButton or TEdit
I have a couple of Buttons and Edits and want to get their names into two procedures but can not figure out how.我有几个 Buttons 和 Edits,想把它们的名字放到两个程序中,但不知道怎么做。 I have set the respective event into OnClick.
我已将相应的事件设置为 OnClick。
When running I am not getting the item name.运行时我没有得到项目名称。 It only shows TButton'' and TEdit
它只显示TButton''和TEdit
Can anyone give me a hint?谁能给我一个提示?
Regards Peter Sweden问候彼得瑞典
From a TButton OnClick event handler, you can get the button name using this code:从 TButton OnClick 事件处理程序中,您可以使用以下代码获取按钮名称:
procedure TForm1.L1_1Click(Sender: TObject);
begin
Memo1.Lines.Add((Sender as TButton).Name);
end;
procedure TForm1.CheckNamesClick(Sender: TObject);
begin
Edit1.Text := (Sender as TEdit).Name;
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.