Hello, I have a problem that I'm trying to solve in VB.NET but having any
success. I have a user-defined control that is button. When the user clicks
this button it changes the forms title bar to the appropriate title; for
example, when the user clicks the ADD button the title in the form says
FORMNAME-[ADD] and the button's text is changed to SAVE. The problem that I'm
having is saving the information that's on the form; this button has no
access to the other control objects and their properties. This button that I
created is used on other forms where data can be added and saved. How can I
access the textbox objects and other objects on the form?

Signature
TC
Claes Bergefall - 26 Oct 2005 08:38 GMT
You need to have a reference to the form
Add a property to your button class and call it,
for example, from the Form.Load event
Public Class MyButton Inherits Button
Private m_myForm As MyForm
Public Property MainForm As MyForm
Get
Return m_myForm
End Get
Set (ByVal value As MyForm)
m_myForm = value
End Set
End Property
...
End Class
...
Public Sub MyForm_Load(ByVal sender As Object, ByVal e As EventArgs) Handles
MyForm.Load
myButton.MainForm = Me
...
End Sub
/claes
> Hello, I have a problem that I'm trying to solve in VB.NET but having any
> success. I have a user-defined control that is button. When the user
[quoted text clipped - 9 lines]
> I
> access the textbox objects and other objects on the form?
Richard A Michaels - 27 Oct 2005 16:44 GMT
Terrance,
You should be able to use the FindForm method of you control to get a
reference to the form where you control is.
Once you have a reference, you can iterate the Controls collection of the
form and map those controls you need.
Richard
> Hello, I have a problem that I'm trying to solve in VB.NET but having any
> success. I have a user-defined control that is button. When the user
[quoted text clipped - 9 lines]
> I
> access the textbox objects and other objects on the form?