By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,491 Members | 3,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,491 IT Pros & Developers. It's quick & easy.

Displaying Controls on Multiple Forms

P: 63
Hi all,

I have a certain number of labels that I want displayed on each of my Windows Forms in my c# Desktop Application project.

Each of the labels is used to open a relavent windows form.

Is it possible to show these labels on each form without having to create them repeatedly on each form?
Can I call them from one class? If so, how?

Thanks.
May 17 '07 #1
Share this Question
Share on Google+
8 Replies


Frinavale
Expert Mod 5K+
P: 9,731
Hi all,

I have a certain number of labels that I want displayed on each of my Windows Forms in my c# Desktop Application project.

Each of the labels is used to open a relavent windows form.

Is it possible to show these labels on each form without having to create them repeatedly on each form?
Can I call them from one class? If so, how?

Thanks.

You could create a Web User Control.
You design the control just like you would any web page.
Then you can use the control on any web page.

-Frinny
May 17 '07 #2

P: 63
Hi Frinny,

Its a Desktop Application so any ideas how I do it for this?

Thanks.
May 17 '07 #3

Frinavale
Expert Mod 5K+
P: 9,731
Hi Frinny,

Its a Desktop Application so any ideas how I do it for this?

Thanks.

I'm not sure about desktop applications because I work mostly with web applications. I'm sure there's a User Control class for the desktop applications...try CustomControl.

Sorry desktop applications are unfamiliar waters to me...I've only done a few simple apps mainly created to help me test my web apps.

-Frinny
May 17 '07 #4

P: 63
yup can use a UserControl.cs class.

How do I use this in each form?

Thanks.
May 17 '07 #5

Frinavale
Expert Mod 5K+
P: 9,731
yup can use a UserControl.cs class.

How do I use this in each form?

Thanks.

Design the control the way you like it.
Add public properties to it if you need to be able to access any data within these controls in your forms.

Drag the control onto your form......name it...use it :)

Its like an object only it has a graphical aspect to it to.

-Frinny
May 17 '07 #6

P: 63
thanks. works fine but when it opens a new form it disappears off the original form.

Any ideas why?

thanks again.
May 17 '07 #7

P: 63
Just realised I have this line to hide the original form in the usercontrol class...

this.Hide();

How do I use the above code to hide the relevant form based on which form has been used to perform the code?

thanks.
May 17 '07 #8

Frinavale
Expert Mod 5K+
P: 9,731
thanks. works fine but when it opens a new form it disappears off the original form.

Any ideas why?

thanks again.

I don't understand what is happening.

Do I understand this correctly:
You have a form with the user control on it and can view it perfectly.
You open another form and the user control disappears of the first form??


Just realised I have this line to hide the original form in the usercontrol class...

this.Hide();

How do I use the above code to hide the relevant form based on which form has been used to perform the code?

thanks.
I've never used this sort of thing but I would assume that the Hide() property can be used by the from that owns the control to set its visibility state. Much like the Visible() property in a Web User Control.

-Frinny
May 17 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.