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 / .NET Framework / New Users / September 2005

Tip: Looking for answers? Try searching our database.

windows forms and arguments

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Simon Whale - 21 Sep 2005 11:45 GMT
Hi,

i am writing a project that uses a treeview as its main application
navigation for the many parts of the program.  i have one part when i need
to display customer information in a child window, i thought i would be able
to overide the new() in the form but this returns an error.

my question is what would be the best way off passing a argument from the
treeview to a form that i want to open? can somebody point me in the right
direction

Many thanks
Simon Whale
Cowboy (Gregory A. Beamer) - MVP - 21 Sep 2005 13:24 GMT
You can overload the constructor in a class:

Public Class TestClass
   Public Sub New()
       'Do nothing here
   End Sub

   Public Sub New(ByVal x As String)
       'Set property here
       _x = x
   End Sub

   'Field declaration
   Private _x As String

   'Proeprty declaration
   Public Property X() As String
       Get
           Return _x
       End Get
       Set(ByVal Value As String)
           _x = Value
       End Set
   End Property
End Class

Signature

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

> Hi,
>
[quoted text clipped - 9 lines]
> Many thanks
> Simon Whale
Cowboy (Gregory A. Beamer) - MVP - 21 Sep 2005 13:34 GMT
As a follow up, since it may not be completely obvious that a form is just
another type of class. Here is a form constructor overloaded:

   Public Sub New(ByRef x As String)
       'Should always call default constructor
       Me.New()

       'Set field
       _x = x
   End Sub

To instantiate the form:

Dim f As New Form2("x")
f.Show()

Signature

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

> You can overload the constructor in a class:
>
[quoted text clipped - 35 lines]
> > Many thanks
> > Simon Whale

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.