Solved

Need to reload main form

Posted on 2004-08-31
5
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

733 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