Windows Develop Bookmark and Share   
 index > Windows Forms General > Switching between one form to another in MDI application take mutch time,How i can minimise switching time?
 

Switching between one form to another in MDI application take mutch time,How i can minimise switching time?

hello friends,
I am working on MDI Application which contain a number of forms when i switch from one form to other it takes some time which i want to minimize, each form contains 20-40 controls and forms load event contain code for database access and fill that data in third party controls like Data Grid controls or custome controls!

Details: After application load i try to open 2-4 forms in Mdi-parent window as child form when i switch from one child from to another it take long time (few seconds) i want to minimize that time.

Application developed in : .net 2.0(using vb.net & C#.net)
please can u help me to solve this problem?
Dipak_Patil  Friday, September 04, 2009 9:25 AM
Hi Dipak_Patil,

Could you please provide a code snippet or what you did when you switch from one from to another?
Based on my understanding, you might handle the Activated event and write some code which costs so much time.

Regards,
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Monday, September 07, 2009 8:07 AM
Hi Aland Li ,

Thanks for reply.

In my Application I write a code in 1)Form_Load 2) Form Closing 3)form Closed events

1) In Form Load : Mainly I perform Database operation and fill data in Third party controls as well as in my custom controls.
2)From Closing : If Data in control get modified and changes not save in database then i put message box "Do you want save changes?" and if yes call function
for Update data.
3)closed event : in closed event i write code for conditional checking and one database operation which perform update operation on one record.
4)activated event :few forms are using small amount of code (but i did not using that forms for switching)

Details of controls used in form :
1).net controls like :label,text box,combo box,tree view,data grid,etc
2)Third party controls :c1Controls(http://www.componentone.com/SuperProducts/FlexGridWinForms/)
DSOframer (control for show Microsoft word document and edit it)
3)custom control : developed by grouping 2-4 .net controls

i call 3-4 forms in MDI application and after loading forms i try to switch from one form to another using windows menu
after that i observe controls are slowly appear on screen and time to complete this switching is around few minutes.

i thought time required to painting components is more while switching to another form.

Thanks & Regards,

Dipak Patil



Dipak_Patil  Tuesday, September 08, 2009 5:26 AM

Hi Dipak_Patil,

Thank you for providing much information about your issue. From your description, the operations those would often cost too much time, such as contrls loading, database updating, are all done in the Load, Closing, Closed event handlers. But these events would not be fired when we switch from one form to another in a general case. Instead, the activated and deactivate events would be fired.

Based on my understanding, we need to trace the code executing and figure out which part costs most of the time. These are the steps:
1. Add some code to the start of some event handlers or methods to show whether they are executed when we switch a form. The code can be like this:
Console.WriteLine("method name");
Then you can see the output messages in the Output window of the visual studio.
2. In the methods or handlers those are executed when we switch a form, output the time a code snippet costs by adding code like below:

    public class Form99 : Form
    {
        private DateTime _time;

        private void Form99_Load(object sender, EventArgs e)
        {
            //Save the start time.
            _time = DateTime.Now;
            
            //Executs some code about loading controls here.

            //Output executing time.
            Console.WriteLine(String.Format("Loading controls costs time:{0}", DateTime.Now - _time));
            //Reset the time.
            _time = DateTime.Now;
        }
    }
Regards,
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Tuesday, September 08, 2009 7:59 AM
This MSDN page details how to optimize the datagridview control.
Wole Ogunremi  Tuesday, September 08, 2009 8:23 AM

Hi,

We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Friday, September 11, 2009 6:20 AM

You can use google to search for other answers

Custom Search

More Threads

• need help regarding C# directory dialog box
• Form.Show() shows form minimized!
• dateTimePicker Values
• DataGridView Combo - Ctrl-0 key press
• Application::Exit() does nothing !
• Determining a keystroke combinaiton
• Saving a Path to Configuration
• How to make a licience expire?
• RichTextBox: text back color
• Dll reference issue