can i dynamicly access object from name of object
-
hi i have 2 form in my program publis object from form2 for example "Frm_User" that new in load of mainform and have a filed for example "AllowEdit" i can access to this filed by Frm_User.AllowEdit but i want to find a way that access "AllowEdit" by know name of this filed in other form it mean that i want find a way to dynamically access obj of form2 "Frm_User" by Name and then change that field in mainForm can any one help me thnx
-
hi i have 2 form in my program publis object from form2 for example "Frm_User" that new in load of mainform and have a filed for example "AllowEdit" i can access to this filed by Frm_User.AllowEdit but i want to find a way that access "AllowEdit" by know name of this filed in other form it mean that i want find a way to dynamically access obj of form2 "Frm_User" by Name and then change that field in mainForm can any one help me thnx
Have you tried casting the object? If the object is different everytime and you can't edit the objects to use an interface with "allowEdit" then maybe you can try using "reflection" methods to get access. Look up those things then ask for specific help.
-
Have you tried casting the object? If the object is different everytime and you can't edit the objects to use an interface with "allowEdit" then maybe you can try using "reflection" methods to get access. Look up those things then ask for specific help.
i know with reflection we can access all property and method with the instance of the object but my problem is i want to create instance of instance of the object from a string that contain name of that object for example : i know that object of from2 is "Frm_User" and string whith this code
string temp="Frm_User";
can i access the object of form 2 with temp?and change property and and field of that?
-
hi i have 2 form in my program publis object from form2 for example "Frm_User" that new in load of mainform and have a filed for example "AllowEdit" i can access to this filed by Frm_User.AllowEdit but i want to find a way that access "AllowEdit" by know name of this filed in other form it mean that i want find a way to dynamically access obj of form2 "Frm_User" by Name and then change that field in mainForm can any one help me thnx
-
i know with reflection we can access all property and method with the instance of the object but my problem is i want to create instance of instance of the object from a string that contain name of that object for example : i know that object of from2 is "Frm_User" and string whith this code
string temp="Frm_User";
can i access the object of form 2 with temp?and change property and and field of that?
Have a look at Activator.CreateInstance(). :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages