The Form1.ActiveForm thing works fairly well, but if you minimize the form while it is trying to do something with it, Form1.ActiveForm isn't set and an exception occurs. A better way may be:
Put this in the module:
And call init() from the windows form designer generated code:
Put that in all your forms and MyForm will always reference the last constructed form (the active form!).
I'm pretty new to this so I'm not sure if this is a good or a bad idea, but it seems to work great for me!
Dan
Put this in the module:
Code:
Public MyForm As System.Windows.Forms.Form
Public Sub init(ByRef thisForm As System.Windows.Forms.Form)
MyForm = thisForm
End Sub
And call init() from the windows form designer generated code:
Code:
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
init(Me)
End Sub
Put that in all your forms and MyForm will always reference the last constructed form (the active form!).
I'm pretty new to this so I'm not sure if this is a good or a bad idea, but it seems to work great for me!
Dan