المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : sending Form to User Control that has written in another project



C# Programming
01-04-2010, 02:11 PM
I have written a User Control and made it dll from a classLibrary Project.
This User Control get the Name of the Form (in Project that we use this dll) in textbox1 and then do something with the controls on this form. Now my question is how i can Cast textbox1.Text (of this user control) to Form ?
see i use this user control in FormA and when the project runs it gets any form name execpt itself(the form that has this user control) in textbox1 (this textbox1 is also in the user control)and then the user control brings out all control on that form and show all properties of that control.

I have used this code in User Control:
Type type = Type.GetType(txtFormName.Text, false, true);
Form frm = Activator.CreateInstance(type) as Form;

I get this error :
Value cannot be null.
Parameter name: type.



Alert :
This user control has been made in another project and i have build DLL and now I use this DLL in my another projects.