Ok, so I am really and truly a beginner at C#. I have been programming for some time but just beginning to learn this language. Here is what I am trying to accomplish. I have created a little application using the main window as a MDI and a child window. There are three buttons in the main window, New Window (when pushed will add a new child window to the MDI), Cascade and Tile (these will arrange the windows within the MDI). Basically I want to disable the buttons if the child window count becomes 0.
I have the following method that I have placed in the main window and in a separate class, each causing me different challenges.
public void UpdateButtons(Boolean ButtonState)
{
if (ButtonState)
{
cascadeButton.ForeColor = Color.FromArgb(0, 0, 160);
tileButton.ForeColor = Color.FromArgb(0, 0, 160);
}
else
{
cascadeButton.ForeColor = Color.FromArgb(202, 202, 255);
tileButton.ForeColor = Color.FromArgb(202, 202, 255);
}
cascadeButton.Enabled = ButtonState;
tileButton.Enabled = ButtonState;
}
I cannot for the life of me figure out how to call this from the Closing event in the child class. I have tried to create a variable that references the main window from within the ChildWindow_FormClosing event “Form MainWin = this.MdiParent();” however the method is not there. I am sure it is a simple answer. If there is anyone that can help me I would greatly appreciate it.
P.s. I have also tryied moving the method to a separate class and calling it that way, which allows me to see the method and call it however I am not able to reference the controls.
Thanks for your help
Patrick