Communicating between a User Control and a Class

  • Thread starter Thread starter Paul Bromley
  • Start date Start date
P

Paul Bromley

Hi,

Can someone point me in the right direcion here. I have been a hobbyist
programmer for some time with VB6 and am moving to Vb.Net. I am afraid that
in the past I did not uderstand too well how to uses Classes, but realise
that I need to do this to use Vb.Net. Hence I have 'bitten the bullet and am
trying hard. I seem to be making soem headawy, adn I can see the advantages
re encapsulation and code re-use.

Now to my question - I have created a user control and need to communicate
with a Class that I have written. If I placed the Calss inside the control
then I would have no problem in accessing a Property or a method in the
Class. However I do need that Class to be available from my program itself,
so I should not be placing this in the control. I have done a lot of
searching and eading about this to try to figure it out, and am coming to
the conclusion that I should be learning about Delegates to achive this.
So - please help to point me in the right direction - should I be looking at
Delegates or should I be looking at Events? I started looking at Events, and
Delegates to me look a simpler concept for me to grasp.

Can anyone give me any very SIMPLE examples of how I can invoke a method or
set a property from another Class? SOrry if I have this all wrong - I seem
to be on a very steep learning curve at the moment, and although some things
are 'clicking' into place, I am not fully there yet!!

Many thanks

Paul Bromley
 
Paul Bromley said:
Hi,

Can someone point me in the right direcion here. I have been a
hobbyist programmer for some time with VB6 and am moving to Vb.Net. I
am afraid that in the past I did not uderstand too well how to uses
Classes, but realise that I need to do this to use Vb.Net. Hence I
have 'bitten the bullet and am trying hard. I seem to be making soem
headawy, adn I can see the advantages re encapsulation and code
re-use.

Now to my question - I have created a user control and need to
communicate with a Class that I have written. If I placed the Calss
inside the control then I would have no problem in accessing a
Property or a method in the Class. However I do need that Class to be
available from my program itself, so I should not be placing this in
the control. I have done a lot of searching and eading about this to
try to figure it out, and am coming to the conclusion that I should
be learning about Delegates to achive this. So - please help to point
me in the right direction - should I be looking at Delegates or
should I be looking at Events? I started looking at Events, and
Delegates to me look a simpler concept for me to grasp.

Can anyone give me any very SIMPLE examples of how I can invoke a
method or set a property from another Class? SOrry if I have this all
wrong - I seem to be on a very steep learning curve at the moment,
and although some things are 'clicking' into place, I am not fully
there yet!!

Many thanks

If you want to access an object, you need a reference. If it's not
available, you have to make it available. Where when and how depends on the
circumstances. Usually, the reference is passed as an argument of a
procedure. Could you please explain what's the purpose of the class and the
Usercontrol and what they do? I'd need this information to find the best
solution. I guess, you won't need Delegates.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Back
Top