porkVT
asked on
Need to reload main form
I currently have a control array of buttons that are dynamically created in the form_load event based on input from a .ini file. I am providing the user a way to modify this .ini file within my application. however, if they add or delete an entry from the file, i have no way to be able to update the buttons on the main form to reflect this.
I thought about moving the button creation code into the Paint event, but it won't let me remove controls from there.
Only solution I could come up with is to launch another instance of my application and close the existing one. It seems kinda crude though, and I'd like to find a better way. Any suggestions?
I thought about moving the button creation code into the Paint event, but it won't let me remove controls from there.
Only solution I could come up with is to launch another instance of my application and close the existing one. It seems kinda crude though, and I'd like to find a better way. Any suggestions?
Have an application level variable in a module called something like
Public frmMainRef As frmMain
Have a procedure in a module called say ReloadMainForm
With the following code in the module:
Option Explicit
Public frmMainRef As Form1
Public Function ReloadMainForm()
Set frmMainRef = New Form1
frmMainRef.Show
End Function
And the following code in the form and a command button:
Option Explicit
Private Sub Command1_Click()
Unload Me
ReloadMainForm
End Sub
Everything in your application that needs to refer to the main form should just refer to the global variable frmMainRef.
JR
Public frmMainRef As frmMain
Have a procedure in a module called say ReloadMainForm
With the following code in the module:
Option Explicit
Public frmMainRef As Form1
Public Function ReloadMainForm()
Set frmMainRef = New Form1
frmMainRef.Show
End Function
And the following code in the form and a command button:
Option Explicit
Private Sub Command1_Click()
Unload Me
ReloadMainForm
End Sub
Everything in your application that needs to refer to the main form should just refer to the global variable frmMainRef.
JR
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Zaphod.