Posted on 2006-11-09
I am really looking for the best way to achieve this as I cannot undertsnad how I would approach it.
In my Form1 Code, I create a class, which is NOT nested. In this class I use ParentForm, thinking that upon Initializing the class in the Form Class OnLoad that it would know that Form1 is the ParentForm. Obviously I found that this did not work. So my question is,
Is passing the Form itself as an overload the only way to reference the form I want? Or is there a way where the class can adapt and realise that the parent form is the one whichg intialized it.
Here is my class, and how I have tried to get the parentForm
public class BlackBoard : Form
private Form _ParentForm;
_ParentForm = ParentForm;
public void DrawBlackBoard()
Graphics g1 = CreateGraphics();
Rectangle BlackBoard = new Rectangle(10, 150, _ParentForm.Width - 20, _ParentForm.Height - 160);
SolidBrush BlackPaint = new SolidBrush(Color.Black);