Click here to Skip to main content
11,805,316 members (66,915 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Application
I'm developing window application 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 11-Jun-12 22:33pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

If you mean that you are storing the name of thr form class in the database, as in:
MyForm form = new MyForm();
And you store the string "MyForm" in your db, you can do it with reflection:
Type t = Type.GetType("MyNamespace." + "frmMyFormClass");
Form c = Activator.CreateInstance(t) as Form;
Member 3962514 at 12-Jun-12 5:05am
Thanks for your help this code working...,
OriginalGriff at 12-Jun-12 5:14am
You're welcome!
OriginalGriff at 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 at 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 at 30-May-13 2:34am
how to access methods of mdi forms while convert string to form object in c# window application
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Member 3962514 at 13-Jun-12 5:47am
i need to open submenu inside the Menu.
can you help me on this...,

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 |
| |

i need to display the child form inside the parent form(menu form)
because of menu bar should be showind all the forms..,

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

  Print Answers RSS
0 OriginalGriff 315
1 Sergey Alexandrovich Kryukov 200
2 Richard Deeming 200
3 CPallini 160
4 CHill60 150
0 OriginalGriff 3,265
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 30 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100