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 / Design Time / June 2004

Tip: Looking for answers? Try searching our database.

How do I overload Show?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Fairless - 15 Jun 2004 20:56 GMT
Could someone please explain how I overload the Show() method of a form?

Suppose I select a record from a datagrid on Form1, then I want to show the
details of the selected record by opening Form2 using say the CustomerID as
an 'argument' to the Show method.

So, in Form1 I would have code such as:

Sub GetSelectedRecord()
   Form2.Show(CustomerID)
   Me.Close()
End Sub

... and in Form2 I woudl have code such as:

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
   ..... code to read a record from a database using the CustomerID
End Sub

Many Thanks

Paul.
Stoitcho Goutsev \(100\) [C# MVP] - 16 Jun 2004 15:59 GMT
Hi Paul, you have no problem overloading Show method. Juas add the new Show
method.

class FooForm: Form
{
   public void Show(int customerID)
   {
       .....
       base.Show();
   }
}

Anyways keep in mind that you cannot call that method if you have a
reference to the base class.
For example:

Form f = new FooForm();
f.Show(custID);

this is an error since Form class doesn't declare such an overload. What one
can do about it is to cast the reference to the right type

((FooForm)f).Show(custID);
or (which is the same) to use variable of FooForm type.

FooForm ff = (FooForm) f;

ff.Show(custID);

Signature

HTH
Stoitcho Goutsev (100) [C# MVP]

> Could someone please explain how I overload the Show() method of a form?
>
[quoted text clipped - 19 lines]
>
> Paul.

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.