Re: Passing a Parameter to a Form when Opening
From: Saurabh (saurabh_at_nagpurcity.net)
Date: 02/18/04
- Next message: david: "How to add the missing template back"
- Previous message: Suresh rao: "RE: Passing a Parameter to a Form when Opening"
- In reply to: Suresh rao: "RE: Passing a Parameter to a Form when Opening"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Feb 2004 15:30:45 -0000
I ma not sure I understand your problem. There are 2 steps in displaying a
form.
1) Create a form object
2) Display the form
Between step 1 and 2, you can set the properties of the form, so if you
create your form, set whatever you want to pass into the object, you can see
that value in the load event of the form.
example class :
public class MyForm : Form
{
public int MyValueToLookInLoadEvent = 0;
public MyForm()
{
}
private void MyForm_Load( object sender, System.EventArgs e)
{
if (MyValueToLookInLoadEvent == 1)
DoSomething();
else
DoSomethingElse();
}
}
example main code
MyForm f = new MyForm();
f.MyValueToLookInLoadEvent = 1;
f.Show();
thats about it.
I guess you will need to decide what you want in MyValueToLookInLoadEvent
and the datatype of it, and other things. You can also have an overloaded
constructor of the form taking a parameter.
Sorry for the C# code, i know you are after VB.NET. Anyways, HTH,
--Saurabh
"Suresh rao" <srao@issgroup.net> wrote in message
news:1238f01c3f632$2459abc0$a001280a@phx.gbl...
> I have the same issue.
> You could either define class member variable and public
> or internal.
>
> I have read the documentation and there is no way that i
> know of to pass parameters to forms in WinForms.
> But i am relatively new to Win Forms (mostly worken on
> Web Forms)
>
> If anyone has something better , please send it to me.
> >-----Original Message-----
> >I have a form called frmCustSearch to search for
> customers against an SQL
> >Server database.
> >
> >The form contains a simple textbox into which the
> Customers surname is
> >typed, and a datagrid then becomes visible on the form
> containing the
> >CustID, Surname, Forename and address of all people with
> that surname.
> >
> >The correct customer is then selected from the datagrid
> and I want to open a
> >new form called frmCustomer to display all the details
> for that customer,
> >using the CustID as an argument when opening the form so
> that it can
> >retrieve the customer record from the database during
> its load event.
> >
> >This is similar to using the OpenArgs in MS Access.
> >But how do I achieve this in VB.NET?
> >Your help is much appreciated.
> >
> >Paul
> >
> >
> >.
> >
- Next message: david: "How to add the missing template back"
- Previous message: Suresh rao: "RE: Passing a Parameter to a Form when Opening"
- In reply to: Suresh rao: "RE: Passing a Parameter to a Form when Opening"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|