2 Basic questions from a new .NET user

  • Thread starter Thread starter Jorge
  • Start date Start date
J

Jorge

Hi,

I am new in .NET and I have some basic questions.

1 - How can I control a object from another form ? I need to change a
checkbox state from another form. What's the best way to do it ?
2 - What is XML and why do we need it ?

Tanks in advance
Jorge
 
1) You have to provide the other form with a reference to your class. This
can be done a number of ways, such as passing the object into the forms
constructor, or creating some manager class that provides a static reference
to the object so that form can get hold of it.

2) Entire books are written on this subject so I will simply be brief. XML
is a markup language (similar to HTML) where you can define data. Some
people use this format instead of a database for small projects. It is
simply a data repository where you can define whatever structure you want
for the data. It also help to separate the data from the presentation. It
can be used for information exchange among different machine which is how
webservices operate. Can't answer why you would need it because it is
dependent on your project and not all projects "need it".
 
For your first question, I would say don't do that. One form should
not access the controls of another. Instead, you should have a class
that holds the values that the form simply reflects. In other words,
you second form should just set a boolean value in either a global
variable or in a class that holds data that both forms could access.
The first form should change its own checkbox to reflect the value of
the data.

Check out the Model View Controller design methodology.

Here's a link: http://tinyurl.com/3398d
 
Back
Top