I have a user control which I load into different flowlayoutpanels, on different forms etc.
In this user control i have a function like this:
private void button1_Click(object sender, EventArgs e)
{
var C = this.Parent.Parent.Parent.Parent.Parent as STP2Main;
C.DisposeControl(STP_Data.Data.ConfigConfigResource);
}
But how many times I need Parent is dependant on the form I load the control in. So I want to do that on a better way. it is reffering to STP_Design.STP2Main, but when I replace this.Parent etc. with STP_Design.STP2Main I get this error:
'STP_Design.STP2Main' is a 'type', which is not valid in the given context
Any tips?
FindFormmethod of the control. – Olivier Jacot-Descombes Nov 13 '12 at 16:05