469,342 Members | 6,942 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

Displaying Controls on Multiple Forms

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
8 1138
Frinavale
9,735 Expert Mod 8TB
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
Hi Frinny,

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

Thanks.
May 17 '07 #3
Frinavale
9,735 Expert Mod 8TB
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
yup can use a UserControl.cs class.

How do I use this in each form?

Thanks.
May 17 '07 #5
Frinavale
9,735 Expert Mod 8TB
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
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
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
9,735 Expert Mod 8TB
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.

Similar topics

2 posts views Thread by Debster | last post: by
2 posts views Thread by moumita | last post: by
reply views Thread by Marcus Kwok | last post: by
1 post views Thread by blueheelers | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.