将一个字符串映射为一个Delphi页面控件属性名
2009-10-19 22:33
411 查看
Code
uses TypInfo;
function TForm1.SetControlProp(ComStr, value: string): boolean;
var ComName, ComProp: string;
i: integer;
Loop: Integer;
PropInfo: PPropInfo;
cp: TComponent;
begin
i := Pos('.', ComStr);
if i > 0 then
begin
ComName := copy(ComStr, 1, i-1);
ComProp := Copy(Comstr, i+1, 1000);
cp := FindComponent(ComName);
PropInfo := GetPropInfo(cp.ClassInfo, ComProp);
if Assigned(PropInfo) then
SetStrProp(cp, PropInfo, value);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
SetControlProp('button1.caption', 'test'); //設置button1的caption 為 test
end;
uses TypInfo;
function TForm1.SetControlProp(ComStr, value: string): boolean;
var ComName, ComProp: string;
i: integer;
Loop: Integer;
PropInfo: PPropInfo;
cp: TComponent;
begin
i := Pos('.', ComStr);
if i > 0 then
begin
ComName := copy(ComStr, 1, i-1);
ComProp := Copy(Comstr, i+1, 1000);
cp := FindComponent(ComName);
PropInfo := GetPropInfo(cp.ClassInfo, ComProp);
if Assigned(PropInfo) then
SetStrProp(cp, PropInfo, value);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
SetControlProp('button1.caption', 'test'); //設置button1的caption 為 test
end;
相关文章推荐
- 将一个字符串映射为一个Delphi页面控件属性名
- 将一个字符串映射为一个Delphi页面控件属性名(通过FindComponent和GetPropInfo找到这个控件指针)
- 如何将一个字符串映射为一个Delphi控件属性名
- 在(二)的基础上,给用户控件添加一个新的属性。用于返回一个字符串
- C# .NET 遍历一个Web页面中所有的TextBox控件 并设置读写属性
- 得到页面所有的form内对象数值——————为一个控件加一个客户端属性
- 关于enum ,调用webservice,用户控件与主页面之间的交互,datsource属性,net面试题,反射类生成sql语句,URl重写一个小实例
- 统计一个页面有相同属性的控件有多少个
- 一个包含上传控件的用户控件把信息传递给包含页面的方法
- 在Jsp页面里面将Struts标签所取的值赋给一个字符串
- 比如xib中设置设置一个UI控件的属性
- 11_5_1创建一个集合类People ,它是下述Person类的集合,该集合中的项可以通过一个字符串索引符来访问,该字符串索引符是人的姓名,与Person.Name 属性相同:
- 一个页面引用多个相同的用户控件时js失效
- Delphi多线程的OnTerminate属性(附加一个关于临界区线程同步的例子)
- 开发日志:hibernate映射,使表中的一个字段对应实体中的多个属性
- Delphi里使用SPComm串口控件的一个乌龙BUG
- SpringMVC学习系列(3) 之 URL请求到Action的映射规则 在系列(2)中我们展示了一个简单的get请求,并返回了一个简单的helloworld页面。本篇我们来学习如何来配置一个acti
- Multiple-View ViewPager-如何实现Viewpager控件的一个页面展示多个page以及回弹效果
- app每个页面都有一个相同的浮层控件 实现思路
- JQuery Uplodify上传附件(同一个页面多个uplodify控件解决方案)