The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Updating .NET user controls on the screen

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Richard Jonas

Posts: 147
Nickname: rjonas
Registered: Nov, 2005

Richard Jonas is a .NET sofware developer living in the UK.
Updating .NET user controls on the screen Posted: Aug 10, 2006 1:19 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Richard Jonas.
Original Post: Updating .NET user controls on the screen
Feed Title: Richard Jonas
Feed URL: http://feeds.feedburner.com/blogspot/ouNA
Feed Description: Richard Jonas's blog about .NET, web development and agile methodologies.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Richard Jonas
Latest Posts From Richard Jonas

Advertisement
I have some user controls that I need to add a lot of data to. This can be slow as the screen display is updated when each item of data is added. It also makes the dislpay flicker.

I couldn't find an equivalent of the BeginUpdate and EndUpdate functions in .NET 2.0, but it is possible to call the Windows API functions as follows.



private const int WM_SETREDRAW = 11;

[System.Runtime.InteropServices.
DllImport("user32.dll")]
static extern bool SendMessage(IntPtr
hWnd, Int32 msd, Int32 wParam, Int32
lParam);

///
/// Stop updates while we are
/// filling a control with data
///
protected void BeginUpdate()
{
SendMessage(this.Handle, WM_SETREDRAW, 0, 0);
Cursor.Current = Cursors.WaitCursor;
}

///
/// Restart updates
///
protected void EndUpdate()
{
SendMessage(this.Handle, WM_SETREDRAW, 1, 0);
if (Parent != null)
{
Parent.Invalidate(true);
}
Cursor.Current = Cursors.Default;
}


I included these in a base class used by all my user controls, and added code to change the cursor to a wait cursor whilst the control was updating.

Read: Updating .NET user controls on the screen

Topic: Commerce Server futures Previous Topic   Next Topic Topic: WSSv3 and MOSS 2007 Themes / Skins

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use