Re: Making a method public
- From: bob <startatbob_clegg@xxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 14 Sep 2007 11:30:59 +1200
On Thu, 13 Sep 2007 16:48:10 -0500, "Tom Woods" <twoods@xxxxxxxxxxx>
wrote:
I'm new to C# and was wanting to access a method in the main form fromHi Tom,
another form
frmMain has a method as such:
public void AddNewForm(string s, int Id)
{
}
However when I'm in a click event in another form, I cannot see AddNewForm
when addressing frmMain.AddNewForm.
Any one know what I'm I doing wrong?
Thanks,
Tom
I am assuming that you want to access an instance of frmMain that will
be running at the time and frm2 is instantiated by some action on
frmMain.
So declare a public variable of type frmMain in frm2 and assign it
when you are instantiating frm2
i.e.
in frm2
public frmMain myFrmMain;
In the appropriate point in frmMain
frm2 f = new frm2();
f.myFrmMain = this;
f.show();
hth
Bob
.
- Follow-Ups:
- Re: Making a method public
- From: Peter Duniho
- Re: Making a method public
- References:
- Making a method public
- From: Tom Woods
- Making a method public
- Prev by Date: Re: A question about Threads
- Next by Date: Re: Pattern Match
- Previous by thread: Making a method public
- Next by thread: Re: Making a method public
- Index(es):
Relevant Pages
|