473,396 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Closing a form and calling main form's function

Hey it's me again :)
I will have some more noobish questions today, so prepare yourselves!

So here you go:

In my app when I close a form, I want a menu update script to be ran, because on the other form the user can modify some folders what are present in the menu bar too.

But I can't do that until I change my

public void loadPlugins()

into

public static void loadPlugins()

.

But if I do, some of my commands become invalid.

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. public void loadPlugins()
  2.         {
  3.             DirectoryInfo pluginDir = new DirectoryInfo(Application.StartupPath + "//plugins//");
  4.             DirectoryInfo[] plugins = pluginDir.GetDirectories();
  5.             if (plugins.Length == 0)
  6.             {
  7.  
  8.                 ToolStripItem noAddon = pluginsToolStripMenuItem.DropDownItems.Add("[NO ADDONS]");
  9.                 noAddon.Enabled = false;
  10.             }
  11.             else
  12.             {
  13.  
  14.                 foreach (DirectoryInfo plugin in plugins)
  15.                 {
  16.                     pluginsToolStripMenuItem.DropDownItems.Add(plugin.ToString());
  17.  
  18.                 }
  19.  
  20.             }
  21.         }
Also the other form's onclose event:

Expand|Select|Wrap|Line Numbers
  1. private void PluginManager_FormClosing(object sender, FormClosingEventArgs e)
  2.         {
  3.             MainWindow.loadPlugins();
  4.         }
  5.  
How could I make this PluginManager form run a function of MainWindow without modifying it's loadPlugins() function?
Feb 27 '10 #1
1 2094
Plater
7,872 Expert 4TB
In your main form, attach an event handler to the close event of your other form.
In that handler, you should be able to call your loadPlugins() function
Mar 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Sherwood | last post by:
Greetings, I have the following code (which displays a second form), but it is not working as expected. I want to close the calling form after the dismissing the second form. However, the...
6
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
6
by: Al the programmer | last post by:
I want to catch the Closing event for my form. I created a test windows app using the wizard. I then create the Closing event by clicking the lightning bolt on the properties pane. The code is...
1
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
10
by: Partha Protim Roy | last post by:
Hello, My problem is: I got a Login form, so once the user enter vaild Username & Password another form opens. How do I close the login form?
5
by: Matthew | last post by:
I would like to make it so when a user clicks the X in the upper right corner it hides the form instead of closing it. I have an icon in the system tray, and other forms running. If the main form...
23
by: Chukkalove | last post by:
Im sorry, I dont know the correct description for a hierarchy of parent and child forms. I have a main form that opens a child form modally. This child form in turn opens it's own child form...
14
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.