locked
Which event triggers after successful loading of a control ? RRS feed

  • Question

  • I have multiple panel controls on one form. Some of the panels include many other controls like group boxes,texts, list Boxes etc. So, when i show one of such panel in my form, it shows in a sequential mode (like starts flickering and gets loaded with a delay and not at once). Therefore, i need an event after a control is successfully loaded so that i make it show after its loaded completely. Any suggestions?

     

    Just to add an example idea of the problem:

    If we make a control show on a form we see it at once, but in my case the panel control can be seen while it is being painted on the screen :(

    I want it to get painted and then be shown on the screen.

    Saturday, June 5, 2010 10:01 AM

Answers

  • You need to use Panel1.SuspendLayout

    VB.nET

        Panel1.SuspendLayout()
    
        'Paint your controls
    
        Panel1.ResumeLayout()

    C#

        Panel1.SuspendLayout();
    
        'Paint your controls
    
        Panel1.ResumeLayout();
    • Marked as answer by Helen Zhou Friday, June 11, 2010 2:11 AM
    Monday, June 7, 2010 6:49 AM
  • Hi Hasssan,

    When adding several controls to a parent control, it is recommended that you call the SuspendLayout method before initializing the controls to be added. After adding the controls to the parent control, call the ResumeLayout method. This will increase the performance of applications with many controls.

    See more about SuspendLayout() on MSDN: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.suspendlayout(VS.80).aspx

    Sincerely,
    Helen Zhou


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Helen Zhou Friday, June 11, 2010 2:12 AM
    Thursday, June 10, 2010 7:08 AM

All replies

  • Use flicker free painting of controls.

    http://www.bobpowell.net/doublebuffer.htm


    Amit Bansal http://www.oops4you.blogspot.com/
    Saturday, June 5, 2010 11:58 AM
  • @Amit

    Thanks for the help but this doesn't solve my problem.

    Actually the link refers to bitmap painting on the screen. In my case i have a panel control that shows on the screen asynchronously. I want it to be seen on the screen at once and not like bit by bit.

     

    Hope i asked correctly this time :p

    Saturday, June 5, 2010 12:56 PM
  • Hi Hasan,

     You are correct but that articel is not only about bitmap painting.

    If you apply the same thing to you panel control then that will not filcker while loading.

    Extended control code:

    this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);

     

    Just write the above lines in your extended control constructor.


    Amit Bansal http://www.oops4you.blogspot.com/

    • Proposed as answer by Amit Bansal Sunday, June 6, 2010 11:38 AM
    Sunday, June 6, 2010 11:37 AM
  • You need to use Panel1.SuspendLayout

    VB.nET

        Panel1.SuspendLayout()
    
        'Paint your controls
    
        Panel1.ResumeLayout()

    C#

        Panel1.SuspendLayout();
    
        'Paint your controls
    
        Panel1.ResumeLayout();
    • Marked as answer by Helen Zhou Friday, June 11, 2010 2:11 AM
    Monday, June 7, 2010 6:49 AM
  • Hi Hasssan,

    When adding several controls to a parent control, it is recommended that you call the SuspendLayout method before initializing the controls to be added. After adding the controls to the parent control, call the ResumeLayout method. This will increase the performance of applications with many controls.

    See more about SuspendLayout() on MSDN: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.suspendlayout(VS.80).aspx

    Sincerely,
    Helen Zhou


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Helen Zhou Friday, June 11, 2010 2:12 AM
    Thursday, June 10, 2010 7:08 AM