您的位置:程序门 -> .net技术 -> vb.net



已知控件名(string)和属性名(string)如何用下面的函数


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


已知控件名(string)和属性名(string)如何用下面的函数
发表于:2007-08-02 15:19:14 楼主
function   getproperty(byval   obj   as   component,   byval   propertyname   as   string)
发表于:2007-08-02 15:19:571楼 得分:0
在线等..
发表于:2007-08-02 15:24:512楼 得分:0
按该函数设计思路,
以一个   textbox   textbox1   为例
dim   sstr   as   string   =   getproperty(textbox1, "text ")
发表于:2007-08-02 15:25:453楼 得分:0
理想的执行结果应该与   sstr   =   textbox1.text   等效
发表于:2007-08-02 15:25:584楼 得分:0
function   getproperty(byval   obj   as   component,   byval   propertyname   as   string)
---------------------------------------------------------------------------------
第一个参数应该是控件对象吧   ,第二个参数是属性名称
-----------------------------------------------------------------
没用过,学习
发表于:2007-08-02 15:27:185楼 得分:0
是啊
我现在要从数据库中读取控件名(string)和属性名(string)后,怎么用啊
发表于:2007-08-02 15:28:136楼 得分:0
提示用反射
发表于:2007-08-02 15:58:497楼 得分:0
private   sub   button15_click(byval   sender   as   system.object,   byval   e   as   system.eventargs)   handles   button15.click
                me.controls( "label3 ").forecolor   =   color.royalblue
        end   sub
发表于:2007-08-02 16:05:538楼 得分:0
楼上
那如果控件是在窗体下的容器里的呢?
发表于:2007-08-02 16:31:219楼 得分:0
dim   sstr   as   string   =   getproperty(me.controls( "textbox1 "), "text ")
发表于:2007-08-02 16:42:0510楼 得分:0
lz看来还发了不少的帖子啊。问题解决了
发表于:2007-08-02 20:44:3611楼 得分:0
jf   up   学习
发表于:2007-08-02 20:59:0712楼 得分:0
up


快速检索

最新资讯
热门点击