Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / October 2005

Tip: Looking for answers? Try searching our database.

Access To Controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Terrance - 25 Oct 2005 18:41 GMT
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.