Click here to Skip to main content
16,019,876 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
how i can call an another class in form application if it is inherited by System.Windows.Forms.UserControl.I know we cant call it by using instance.showDilog() method then how to call such a cs files.thanks
Posted
Updated 3-Apr-11 20:10pm
v2

I think you are confused about UserControl...

A UserControl is not a Form. It can't be displayed with ShowDialog. It is a control (like a Button or TextBox or whatever) which you can put inside a Form.

If you want to put controls inside a form and then display that form using ShowDialog, then you don't need a UserControl. Just add a Form in your project and put the controls inside it.
 
Share this answer
 
Comments
Sander Rossel 4-Apr-11 12:16pm    
Exactly!
Sergey Alexandrovich Kryukov 5-Apr-11 2:02am    
Exactly. Also, there is no such thing as "call a class".
My 5.
--SA
You treat it the same way as you treat all controls.
So you either drag it onto a form from your toolbox, or you add it to the Controls collection of another Control.
MyControl myControl = new MyControl
Form1.Controls.Add(myControl)
 
Share this answer
 
Comments
Member 7685573 4-Apr-11 2:48am    
Form1 is my original form & ChartApperence is my another form.& I want to call chartapprence form dilog from form1 then how to do it
Sander Rossel 4-Apr-11 3:06am    
How to open a form is the absolute basics... Perhaps you should read a book before posting questions like that. It will not help you. You already gave the answer in your first question anyway... instance.ShowDialog.
Member 7685573 4-Apr-11 3:12am    
but instance.showDilog() is used for forms but i have inherited usercontrole to my form so instance.showdilog is not get available
Sander Rossel 4-Apr-11 3:24am    
So put your usercontrol on a form and show the form...
Member 7685573 4-Apr-11 3:30am    
actually there is a class CurApp:System.Windows.Forms.UserControl in that class they have used their control & I want to add that class to my class ie. form class & showdilog.so that it will display chart dilog of second class thanks for replay

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