使用字符串变量作为控件,项目和对象名称 [英] Use string variable for control, item and object name
问题描述
我需要类似的东西"
string obj= something; this.obj.Visible = false;
不是
this.Controls[SomeButtonName].Visible = false;
或者告诉我从字符串执行此代码的方式"
string command = "this.something.visible=false"; execute(command);
非常感谢.
您可能想查看devexpress论坛和博客.
他们对此有更多信息.
我需要类似的东西" :字符串 SomeButtonName = " button1"; this .Controls [SomeButtonName] .Visible = false ;或告诉我如何从字符串中执行此代码"
string command = "this.btn1.visible=false"; execute(command);这是一个推迟编译和将字符串作为C#代码执行的问题,这是一个更深层的问题:如果搜索CP,您会发现在运行时执行时有许多出色的资源字符串中的代码.
我完全不清楚这两个问题与您提出的问题的总体权限之间的关系.
但是,希望对您有所帮助!
您尝试过System.Runtime.CompilerServices命名空间吗?
"I need something like that"
string obj= something; this.obj.Visible = false;
Not
this.Controls[SomeButtonName].Visible = false;
"Or tell me the way to execute this code from the string"
string command = "this.something.visible=false"; execute(command);
Thanks very much.
You might want to check on the devexpress forums and blogs.
They have some more information about this.
"I need something like that"string ctrlname = btn1; this.ctrlname.Visible = false;Why you would ever want to use code like that is not something I understand, but it can be done:
string SomeButtonName = "button1"; this.Controls[SomeButtonName].Visible = false;"Or tell me the way to execute this code from the string"
string command = "this.btn1.visible=false"; execute(command);This, a question of deferred compilation and execution of a string as C# code, is a much deeper question: you will find, if you search CP, several excellent resources on executing at run-time code in a string.
I am completely unclear how these two questions relate to the overall issue of permissions raised by your question.
But, hope this helps !
did u try System.Runtime.CompilerServices Namespace ?
这篇关于使用字符串变量作为控件,项目和对象名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!