Inheriting classes

  • Thread starter Thread starter Kevin Blackwell
  • Start date Start date
K

Kevin Blackwell

This is probably a basic c# question, but I'm having problems with it.

I currently have a project that contains two classes. From the calss view.

Class1
Class2

I have included a usercontrol in class 2. I dropped the control into a
form in class one. What I'm looking to do is fill a control's text box
with information from Class1.

(string)Class1.button1.text = (string)Class2.ClassState.Info;

Any help would be appreciated.

Kevin
 
If I understand the problem, usercontrols wrap the contents within, meaning
that you normally do not interact with controls in the usercontrol. What
you can do is make your textbox variable in your UC public, or expose a
property on the usercontrol that will delegate the commend to the textbox.
 
Hi
since you put your usercontrol into class one this means that it is a
member of class one now .. this will allow you ta access all data of class
one .
however to get that data to the textbox control " i think it is a member of
your user control" , you sould make this textbox a public member of the
user control .. this way you can access its text property. Another way to
do it is to write a property of the usercontrol that set and get the text
property of the internal textbox control. this way you don't have to change
the textbox from private to public and it is also a better practice.
hope that would help
 
OK, first let me apologize. I'm new to C# and Visual Studio. With that
said...

I understand the logic of what both of you are saying, but I am just not
understanding how to implement in C#. So here's my set up and what I'm
trying to attempt to do.

In the class viewer..

Project A
+ namespace B
++ Class1
++ Class2

Class1 contains Button1
what I'm interested in is populating the Button.text field.
Class1 is of type UserControl

Class2 contains a string that doesn't get populated until theres an
event. For instance a phone call.
Class2 is of type IDisposable.

So. Say a phone call comes in, Class2 grabs the phone number
information. I'm trying to then update the Button.text field in Class1.

Is there a way for me to call an updateable instance of Class1 within
Class 2?

Thanks in advance..

Kevin
 
Back
Top