I am creating an Extension
method for the .net BindingSource
object. Currently the method needs a Control
passed in (this Control
is the "main" Control
which is normally a UserControl
or a Form
).
I would like how ever, to not have to pass this "parent" Control
in. Is there a way to find a BindingSource
parent Control
? I know there is a Container
but that does not help me or at least I don't think it does.
Currently you call this method like below (C# UserControl
):
//'new Object()' would be the data source
BindingSourceControlName.ExtMethodName(This, new Object());
I would like to dynamically get the parent Control
from the BindingSource
so that I could call the method like below (C# UserControl
):
//'new Object()' would be the data source
BindingSourceControlName.ExtMethodName(new Object());
Is this even possible, maybe using reflection? Thank you for reading!