473,387 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Trying to add controls to the main Form from another class

I am trying to add controls(labels) to the main form from another class
without having the main form as a base class......how do i do this?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
1 2113
You need to get a reference to the main form's instance. Then you can add
the labels without problems.

To do this, simply pass the reference to the form from which you want to add
the labels, while you're instantiatiating it.
The other way to solve this - if you don't have a way of passing that
reference by some reason - is to use a static reference to the main form (as
a private or protected member). Then delcare a method that fetches that
reference - something like getInstance() or something.

Hope that will help you :)

Cheers,
Branimir
--
Branimir Giurov
MCSD.NET, MCDBA, MCT
eAgility LLC

"James Dean" <ka*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I am trying to add controls(labels) to the main form from another class
without having the main form as a base class......how do i do this?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. ...
1
by: James Dean | last post by:
I am trying to add controls(labels) to the main form from another class without having the main form as a base class......how do i do this? *** Sent via Developersdex...
1
by: James Dean | last post by:
I am trying to add controls(labels) to the main form from another class without having the main form as a base class......how do i do this? *** Sent via Developersdex...
4
by: JimC | last post by:
On my main form in a C# program, I create an instance of another form that contains a ListView control, in the usual way, that is: public class frmMain : System.Windows.Forms.Form { // ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.