So it's obviously something simple but I'm losing too much time on this topic already. I have a very simple(as it should be in my opinion) method which task is to iterate through all buttons in my parent form.
Here it is:
public void SetForeColor(BaseForm frm, Form f)
{
foreach (ToolStripButton button in frm.Controls.OfType<ToolStripButton>())
{
MessageBox.Show("Soles clicked"+" "+f.Name.ToString());
}
}
Where BaseForm frm
is the argument that should take the MDIparent
as value. I call this method from another one where I actually get the MDIparent
:
protected void LoadForm<T>(ToolStripButton formButton, string buttonText) where T : Form
{
MainForm frm = this.MdiParent as MainForm;
if (frm == null) frm = this as MainForm;
T sendTo;
....
SetForeColor(frm, sendTo);
But I don't get any response. The LoadForm<T>
function is working fine, so my suggestion is that I'm making mistake in the foreach
but it seems so very straight forward to me...