Solved

Need to reload main form

Posted on 2004-08-31
5
166 Views
Last Modified: 2010-05-02
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?
0
Comment
Question by:porkVT
5 Comments
 
LVL 7

Expert Comment

by:Z_Beeblebrox
ID: 11942327
You could create a subroutine on your form which is responsible for unloading any existing buttons, then loading them based on the ini file. Call this subroutine from your form_load and from wherever you get notified that the ini file has changed.

Zaphod.
0
 
LVL 18

Expert Comment

by:JR2003
ID: 11942551
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
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12561047
PAQed with no points refunded (of 250) %%STAMP%%

Computer101
EE Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now