Click here to Skip to main content
15,886,752 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#

Hi,
I'm developing window application C#.net 2010...

My question is simple, i'm getting form name from database...

now i want to open the form using name/string coming from database...
how to convert string to form object in c# window application

please reply me.........
Posted

You can use
1-string name = Convert.ToString(objName);
2-string name = objName.Tostring();
3-string defaultName;
string.TryParse(objName,out defaultName);

I think these way u can convert a object to string.
 
Share this answer
 
Comments
Member 3962514 13-Jun-12 5:47am    
hi,
i need to open submenu inside the Menu.
can you help me on this...,

eg:-
before click About Us
------------------------
About Us | Help
------------------------

after click About button i need to'
display the chile form it contain inside the MDI form..,
|-----------------------|
|About Us | Help |
|-----------------------|
| |
| frnabout |
| |
|------------------------

note:-
i need to display the child form inside the parent form(menu form)
because of menu bar should be showind all the forms..,
If you mean that you are storing the name of thr form class in the database, as in:
C#
MyForm form = new MyForm();
And you store the string "MyForm" in your db, you can do it with reflection:
C#
Type t = Type.GetType("MyNamespace." + "frmMyFormClass");
Form c = Activator.CreateInstance(t) as Form;
c.Show();
 
Share this answer
 
Comments
Member 3962514 12-Jun-12 5:05am    
Thanks for your help this code working...,
OriginalGriff 12-Jun-12 5:14am    
You're welcome!
OriginalGriff 14-Aug-12 11:56am    
Ask this as a separate question - it doesn't have much relevance to the original question, and we would need more info about exactly what you are doing.
It is considered "hijacking" to ask a question on someone else's thread, and rude! :laugh:
OriginalGriff 14-Aug-12 14:00pm    
This question answers part of your problem, but what remains is not related to the original query - hence it should be a new question.
No need to apologise, you aren't in trouble! :laugh:
Romal from Surat Gujarat, India 30-May-13 2:34am    
how to access methods of mdi forms while convert string to form object in c# window application

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