| re: Call function
There may be an easier way, but....
This depends on whether Function1() uses any member variables or calls other
methods in startClass. If it doesn't, then Function1() probably should be
moved into a Global class and made static.
If it does call other methods, then you could have a reference of it in your
child ClassA:
in ClassA have the following:
System.Windows.Forms.Form _parent = null;
public System.Windows.Forms.Form Parent
{
set
{
_parent = value;
}
}
// then you can call public methods on parent
public function example ()
{
if ( _parent == null )
return;
_parent.Function1();
}
Finally, in startClass, change to the following:
private callClassA()
{
ClassA classA = new ClassA();
classA.Parent = (System.Windows.Forms.Form)this;
classA.ShowDialog();
}
"PawelR" <pawelratajczak@poczta.onet.pl> wrote in message
news:Oa0MWlg1EHA.3092@TK2MSFTNGP10.phx.gbl...[color=blue]
> Hello Group,
>
> In my application I have few class, and I want call function with "master
> class". This is as master form (startClass) and option window (ClassA). My
> question is how call function from startClass in classA?
>
> public startClass : System.Windows.Forms.Form
> {
> static void Main()
> {...}
> public string Function1()
> {...}
> private callClassA()
> {
> ClassA classA = new ClassA();
> classA.ShowDialog();
> }
> }
>
> public ClassA : System.WIndows.Forms.Form
> {
> private void Fuction11()
> {
> //call Function1();
> }
>
> }
>
> Thx PawelR
>
>[/color] |