In that case, pass 'this' as a parameter in the OptionDialog constructor
and create public properties in the MainClass instead.
public MainClass
{
public int Left
{
get
{
return graphStart.Left;
}
set
{
graphStart.Left = value;
RedrawGraph();
}
}
private void Options()
{
OptionDialog od = new OptionDialog(this);
od.ShowDialog();
}
}
public class OptionDialog
{
private MainClass parent;
private TextBox leftBox;
private TextBox topBox;
private TextBox graphBox;
public OptionDialog(MainClass caller)
{
parent = caller;
}
btUpdate_Click(object sender, EventArgs e)
{
parent.Left = Int32.Parse(leftBox.Text);
}
}
> Morten,
>
[quoted text clipped - 62 lines]
>> Happy Coding!
>> Morten Wennevik [C# MVP]

Signature
Happy Coding!
Morten Wennevik [C# MVP]
Marco De Sanctis - 02 Dec 2004 07:45 GMT
Everything's ok with that last example, the only thing I suggest is not to
show the options form as a Modal Form: try using owner-owned relation:
from the graph form code:
private void Options()
{
OptionDialog od = new OptionDialog();
this.AddOwnedForm(od);
od.Show();
}
From OptionDialog form you can refer to Graph Form looking at the property
Owner. Owned forms are great: you can still interact with your main form,
but they are never painted behind their owner. Moreover, if you close or
minimize the Owner Form, all the Owned ones are closed or minimized too.
Bye!
> In that case, pass 'this' as a parameter in the OptionDialog constructor
> and create public properties in the MainClass instead.
[quoted text clipped - 105 lines]
>>> Happy Coding!
>>> Morten Wennevik [C# MVP]
GrkEngineer - 20 Apr 2005 00:55 GMT
I'm trying to implement this, but I'm running into C++ errors. In the .h file
containing my MainClass I include a header referring to the ChildClass. But
when I want to access any methods or variables from the MainClass from my
ChildClass, I need to do a typecast. Well my ChildClass has no clue what
MainClass is. When I try to add an include in my ChildClass the MainClass.h
file to define MainClass I get errors. Please help!
> In that case, pass 'this' as a parameter in the OptionDialog constructor
> and create public properties in the MainClass instead.
[quoted text clipped - 105 lines]
> >> Happy Coding!
> >> Morten Wennevik [C# MVP]