473,402 Members | 2,046 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,402 software developers and data experts.

Forms and UserControls, New to C#

I am working on a basic windows for App using c# and vs.net2003.

I have a usercontrol containing a treeview, and I need to display things on
he main form based on the item selected in the treeview. What is the
bestway to reference the panel (or other controls) on the main form from the
UserControl?

Nov 16 '05 #1
3 1237
A good principle for questions like this is that of loose-coupling. It's
generally a good idea for a user control to know little or nothing about
where it's sited. Better, I think, to raise custom events to the owner when
something interesting happens, and let the owner take whatever action is
appropriate, such as updating the contents of other controls on the form.
This gives you the freedom of making changes to the form without having to
modify the user control's code, and lets the parent form encapsulate all
information about its logic and behavior.

HTH,
Tom Dacon
Dacon Software Consulting

"Johnny Fugazzi" <ab********@ldmkusa.com> wrote in message
news:ua**************@TK2MSFTNGP11.phx.gbl...
I am working on a basic windows for App using c# and vs.net2003.

I have a usercontrol containing a treeview, and I need to display things on he main form based on the item selected in the treeview. What is the
bestway to reference the panel (or other controls) on the main form from the UserControl?

Nov 16 '05 #2
Sounds like it makes sense.
Do you have a good reference or place for information to look into this?
Like I mentioned, I am new to using C# in a windowsForms environment. I
have mostly worked with vb.net in asp.net environments in the past.
"Tom Dacon" <td****@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
A good principle for questions like this is that of loose-coupling. It's
generally a good idea for a user control to know little or nothing about
where it's sited. Better, I think, to raise custom events to the owner when something interesting happens, and let the owner take whatever action is
appropriate, such as updating the contents of other controls on the form.
This gives you the freedom of making changes to the form without having to
modify the user control's code, and lets the parent form encapsulate all
information about its logic and behavior.

HTH,
Tom Dacon
Dacon Software Consulting

"Johnny Fugazzi" <ab********@ldmkusa.com> wrote in message
news:ua**************@TK2MSFTNGP11.phx.gbl...
I am working on a basic windows for App using c# and vs.net2003.

I have a usercontrol containing a treeview, and I need to display things

on
he main form based on the item selected in the treeview. What is the
bestway to reference the panel (or other controls) on the main form from

the
UserControl?


Nov 16 '05 #3
You might look around for a good text on the principles of object-oriented
design. This isn't really a language issue - the principles apply to VB just
as firmly as they apply to C# or C++ or SmallTalk or any other
object-oriented language. In fact, if you were to do a search for such a
book, I'd look for something that didn't concentrate on a single language so
much as it emphasized the language-independent principles.

Sorry I don't have a specific recommendation. I've been doing this for so
long that the primary references I used when I was integrating these
principles are kind of dated now.

I will say, however, that Microsoft's MSDN library and the sample code that
you find there are not necessarily the best examples of good object-oriented
design that you'll come across. So don't take what you find there as gospel.

Best of luck,
Tom Dacon
Dacon Software Consulting

"Johnny Fugazzi" <ab********@ldmkusa.com> wrote in message
news:OQ*************@TK2MSFTNGP11.phx.gbl...
Sounds like it makes sense.
Do you have a good reference or place for information to look into this?
Like I mentioned, I am new to using C# in a windowsForms environment. I
have mostly worked with vb.net in asp.net environments in the past.
"Tom Dacon" <td****@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
A good principle for questions like this is that of loose-coupling. It's
generally a good idea for a user control to know little or nothing about
where it's sited. Better, I think, to raise custom events to the owner

when
something interesting happens, and let the owner take whatever action is
appropriate, such as updating the contents of other controls on the form. This gives you the freedom of making changes to the form without having to modify the user control's code, and lets the parent form encapsulate all
information about its logic and behavior.

HTH,
Tom Dacon
Dacon Software Consulting

"Johnny Fugazzi" <ab********@ldmkusa.com> wrote in message
news:ua**************@TK2MSFTNGP11.phx.gbl...
I am working on a basic windows for App using c# and vs.net2003.

I have a usercontrol containing a treeview, and I need to display
things on
he main form based on the item selected in the treeview. What is the
bestway to reference the panel (or other controls) on the main form
from the
UserControl?



Nov 16 '05 #4

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

Similar topics

6
by: Otie | last post by:
I have a project with a main form and a second form with a grid on it. Neither form is an MDI, thus neither form is a child - they are two independent forms. The CALCULATE button on the main form...
2
by: Emma | last post by:
Hi, I'm developing a GUI with almost all Usercontrols. It's been working wonderfull up till a few weeks ago, and really crashed yesterday. Suddenly I can no longer add some of my usercontrols...
14
by: RL Stevenson | last post by:
What is a reasonable way to manage a complex form with 5 or so tabs with 100 or more controls bound to 5-10 tables in a database? Pasting all those controls, datasets, data adapters directly onto...
4
by: Anders K. Jacobsen [DK] | last post by:
Hi I have some common UserControls i want to share between to sites (on the same mashine but on diffrent virtual paths). right now i have on solution file with aprox 10 projects. 2 of these is...
11
by: Crirus | last post by:
I need to derive the Windows.Forms.Control 2 times so I design a class like this Public Class BMControl Inherits System.Windows.Forms.UserControl Public Class MapControl Inherits BMControl
1
by: Dominic via DotNetMonster.com | last post by:
With a little help from someone in this forum, I am currently creating forms and then embedding them into tabpages, so that I get a display similar to Lotus Notes. I have one container window, so I...
1
by: Dominic via DotNetMonster.com | last post by:
With a little help from someone in this forum, I am currently creating forms and then embedding them into tabpages, so that I get a display similar to Lotus Notes. I have one container window, so I...
0
by: seigo | last post by:
Hello, I faced with the following problem. I have a PlaceHolder on a page and a few UserControls which have custom events, for instance: public delegate void SelectHandler(object sender,...
4
by: Nathan Sokalski | last post by:
In several of my UserControls I add properties. If I access these properties in the CodeBehind of the pages that use the controls, I recieve an error when compiling. The reason for this is because...
7
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.