Click here to Skip to main content
15,914,160 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
"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.
Posted
Updated 27-Jan-12 21:38pm
v6

You might want to check on the devexpress forums and blogs.
They have some more information about this.
 
Share this answer
 
"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:
C#
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 !
 
Share this answer
 
Comments
clover4leaves 30-Jan-12 1:31am    
Thanks BillWoodruff. I've searched many times in CP, and many other forums, and found several excellent resources on executing at run-time code in a string.
But still cannot use
<pre>string command = "this.btn1.visible=false";
execute(command);</pre>
...
clover4leaves 30-Jan-12 1:32am    
I've found many resources and example. They work well for math and messagebox.show().
But not for my need.

Please help me

<pre lang="cs">string command = "this.btn1.visible=false";
execute(command);</pre>
did u try System.Runtime.CompilerServices Namespace ?
 
Share this answer
 
Comments
clover4leaves 30-Jan-12 4:14am    
No, I didn't.
Please give me an example to guide me use it.

Thanks very much.
Now I've solved the problem by re-design the program.
But I've another idea that need your help, please see it here
Set Property For Control By The DLL Or Class
Thanks very much.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900