Getting a Reference to a Control's Parent Form
All .NET Windows Forms controls have a FindForm method that allows you to get a reference to the form on which a control resides. Unfortunately, this method does not work when a control is instantiating (usually the very time you need a reference to the parent form!).
To address this issue, you can call the static GetParentForm method of the MM .NET Form Manager to get a reference to the parent form.
For example, in C#:
public class MyTextBox : TextBox
{
public MyTextBox()
{
Form ParentForm = mmAppDesktop.FormMgr.GetParentForm(this);
// Perform processing
}
}And in VB .NET:
Public Class MyTextBox
Inherits TextBox
Public Sub New()
Dim ParentForm As Form = mmAppDesktop.FormMgr.GetParentForm(Me)
' Perform processing
End Sub
End Class
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 07/05/04
Comment or report problem with topic
