Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Application Window
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 11-Jun-12 23:33pm
Rate this: bad
good
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;
            c.Show();
  Permalink  
Comments
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
good
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.
  Permalink  
Comments
Member 3962514 at 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..,

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



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 30 May 2013
Copyright © CodeProject, 1999-2014
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