How can I access Properties or Methods from One User Control Lib in Another Control

ofern01

Member
Joined
Jan 3, 2006
Messages
9
Programming Experience
10+
I have a Project (component Lib) that has a Form, Button, Label and Text Control all With New Properties and Methods
For Ex: In the Form I added a Method (saveChanges) That Will Perform Some Saving Logic. I have another Control (button) that will Need to call That Method in the form when is pressed. When I try to add the logic to the button, It tell me that the form does not have that method. How can I tell The Button that the method will Exist when I Place the button on the Form.
What I'm trying to do is a library of object that I just need to put together later on and fill in the method logic for the application at that moment. I was able to do this in VFP. Can I Do the Same Here? if not, can you tell me more or less a way or accomplishing what I want to do.
I just want to have a Lib of object that will work together by just adding a few lines of code to the diferent methods or events.

This is a view of the solution (more or less):
MySolution (xyz)
- myProject1 (a Form Component Class)
- myProject2 (a Button Component Class)
- MyProject3 (a Label Component Class)

As you can see, this a library of components That I'm creating to be used on my solutions later on. This way it makes eazy my programming and more structure. (for me)

In myproject1 I have added a few properties and methods. One os the methods is saveChanges().
In myproject2 I have added logic to the button.Click() event. The idea is that when I press the button, it call the savechanges() method on the form (myproject1). At the time of design, the Button here is just an object by itself. It is not a form jet. just a component class. Here is where I have the problem as you can see. How Do I reference the method from here?

The idea is that later on I will save these objects and add them to the toolbox. I will them create a new project based on this form (myproject1) and add the button (myproject2) so that it will work together with the form now. At this point I will have no problem since the button is now on a form where the savechanges method is.

Any Ideas?....
 
make the saveChanges method Public,
VB.NET:
Public Class myProject1
Inherits [SIZE=2]System.Windows.Forms.Form[/SIZE]
[SIZE=2]'...
[/SIZE]Public sub saveChanges()
'...
End Sub
End Class
then you can call it from an instance variable.
VB.NET:
dim myform as new myProject1
myform.saveChanges()
 
Back
Top