Team Foundation Server Hosting
Skip Navigation Links
C# Corner Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » Windows Forms » SuspendLayout C# Forms
       
Author Reply
Administrator
posted 1368 posts
since Sep 10, 2003 
from

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.
Administrator
posted  1368 posts
since  Sep 10, 2003 
from 

 Re: SuspendLayout C# Forms
  Posted on: 06 Mar 2003        0  
I noticed this.SuspendLayout(); and this.ResumeLayout(false); generated by VS.NET automatically for me, maybe you could have a look into these methods.
Administrator
posted  1368 posts
since  Sep 10, 2003 
from 

 Re: SuspendLayout C# Forms
  Posted on: 07 Mar 2003        0  
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.
John JC
posted  1 posts
since  Apr 30, 2006 
from 

 Re: SuspendLayout C# Forms
  Posted on: 05 Aug 2007        0  
try control.BeginUpdate() and control.EndUpdate()
Alan C Balkany
posted  11 posts
since  Sep 12, 2007 
from  Earth

 Re: SuspendLayout C# Forms
  Posted on: 12 Sep 2007        0  

(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 ().

Michael Arrington
posted  1 posts
since  May 15, 2007 
from 

 Re: SuspendLayout C# Forms
  Posted on: 27 Mar 2009        0  
Thanks for the tip.  That is VERY useful!!!  It's now part of my library and it works very well.
       
6 Months Free & No Setup Fees ASP.NET Hosting!
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved