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.