我想使用findclass和findcomponent能够将发送方组件作为过程中的参数传递。
感谢您阅读。
编辑:我使用Delphi 2005
[错误]:E2003未声明的标识符:“文本”
TestMemo.Text := (FindComponent(VonKomponente.name) as
(Findclass(vonkomponente.ClassType.ClassName))).text; -> does not work
TestMemo.Text := (FindComponent(VonKomponente.name) as TEdit).text; -> works
procedure TFormTest.Edit7DblClick(Sender: TObject);
begin
MemoEdit((Sender as TComponent),'table','row');
end;
procedure TFormTest.MemoEdit(VonKomponente :TComponent;table,row : String);
begin
FormTestMemo.Max_Textlaenge := get_length(table,row);
FormTestMemo.Text := (FindComponent(VonKomponente.name) as
(Findclass(vonkomponente.ClassType.ClassName))).text;
If FormTestMemo.Showmodal = MrOk then
begin
...
end;
end;
答案 0 :(得分:2)
您无法执行的操作。您不能将运行时确定的元类类型传递给Strategy.registerStrategies = function(strats) {
Object.keys(strats).forEach(name => {
Strategy.registerStrategy(name, strats[name]);
});
};
运算符。
对于您要执行的操作,您将不得不通过TypInfo
单元(在这种情况下为TypInfo.GetStrProp()
函数)使用旧式RTTI,例如:
as
请注意,并非所有基于文本的组件都具有uses
..., TypInfo;
FormTestMemo.Text := GetStrProp(VonKomponente, 'Text');
属性,有些具有Text
属性,例如:
Caption