Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to reload main form

Posted on 2004-08-31
5
Medium Priority
?
211 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…
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…
Suggested Courses

604 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