Employers - Post Free Jobs
Forum guidelines
AuthorQuestion
SuspendLayout C# Forms
Posted on: 20 Feb 2003
I have written a Flowsheeting GUI, where the user can add, delete reposition UserControls on the screen at runtime and connect them with GDI+ Drawn Lines to represent connections. The only problem is that I can not figure out how to prevent the form redrawing each UserControl one at a time when the form is Zoomed in or out, is there any way to have reposition the usercontrols and resize them before they are redrawn to the screen. I have tried using the suspend and resume layout methods withut any success on the both the parent form and on each user control. In VBA and so on there was a function called ScrenUpdating=false which achieved what I wanted, but in C# I can not find an equivalent command.
AuthorReply
Re: SuspendLayout C# Forms
Posted on: 06 Mar 2003  
I noticed this.SuspendLayout(); and this.ResumeLayout(false); generated by VS.NET automatically for me, maybe you could have a look into these methods.
Re: SuspendLayout C# Forms
Posted on: 07 Mar 2003  
Thanks for the reply, but if you look at the title of the original post or the text, I allready tried these methods and they had no beneficial effect.
Re: SuspendLayout C# Forms
Posted on: 05 Aug 2007  
try control.BeginUpdate() and control.EndUpdate()
Re: SuspendLayout C# Forms
Posted on: 12 Sep 2007  

(I just posted this to another thread, but it appears to be an answer to your question, so I'm reposting it here.  Hope it helps...)

================================

You can try SuspendLayout () before initializing your form and ResumeLayout () after initialization.  Sometimes this doesn't work.  When it doesn't, you can try using the Win32 functions:

Outside of your method:

using Microsoft.Win32;
using System.Runtime.InteropServices;


        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
        private const int WM_SETREDRAW = 11;

 

Before drawing:

            SendMessage(ObjectControlPanel.Handle, WM_SETREDRAW, false, 0);

After drawing:

            SendMessage(ObjectControlPanel.Handle, WM_SETREDRAW, true, 0);

You may then need to call Refresh ().


Re: SuspendLayout C# Forms
Posted on: 27 Mar 2009  
Thanks for the tip.  That is VERY useful!!!  It's now part of my library and it works very well.

SPONSORED BY

Offshore Software and Database Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.