A
Andy
hi, i have a problem calling a method of the mainForm inside another
class
the problem is, that i am not able to create an instance of the main
form because the other class e.g ClassB is in another *.cs file,
wihich is already included in the mainform file... (->circle inclusion
not allowed!)
when i create an object of ClassB in the mainform, i pass the parent
resp. the this pointer to the constructor of CLassB an store this
handle as a Form.
--------------------------------------------------------
in file1.cs:
namespace sample
{
public class MainForm: System.Windows.Forms.Form
{
...
ClassB myClassB = new ClassB(this, ...)
...
public void doSth(int i)
{
...
}
}
}
--------------------------------------------------------
--------------------------------------------------------
in file2.cs:
namespace sample
{
Form m_FrmParent;
public class ClassB
{
public ClassB(Form parent,...)
{
m_FrmParent= parent;
...
}
public callFromClass(int i)
{
//how to call here the "doSth(int i)"
//metod of the parent??
Control.Invoke? delegate? but how??
}
}
}
class
the problem is, that i am not able to create an instance of the main
form because the other class e.g ClassB is in another *.cs file,
wihich is already included in the mainform file... (->circle inclusion
not allowed!)
when i create an object of ClassB in the mainform, i pass the parent
resp. the this pointer to the constructor of CLassB an store this
handle as a Form.
--------------------------------------------------------
in file1.cs:
namespace sample
{
public class MainForm: System.Windows.Forms.Form
{
...
ClassB myClassB = new ClassB(this, ...)
...
public void doSth(int i)
{
...
}
}
}
--------------------------------------------------------
--------------------------------------------------------
in file2.cs:
namespace sample
{
Form m_FrmParent;
public class ClassB
{
public ClassB(Form parent,...)
{
m_FrmParent= parent;
...
}
public callFromClass(int i)
{
//how to call here the "doSth(int i)"
//metod of the parent??
Control.Invoke? delegate? but how??
}
}
}