Solved

Custom control not refreshing on scroll.

Posted on 2009-07-01
3
165 Views
Last Modified: 2012-05-07
Hi,

I have the following code below from a custom component, although my issue is that when I scroll away from the rectangle and then back on the control does not refresh so the rectangle keeps getting larger. I have to force a refresh by switching to a different application then back. How can I sort this?

Thanks,
Uni
public partial class MyCustomControl:ScrollableControl {
 

	//Constructor.

	public MyCustomControl() {

		InitializeComponent();

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

		this.AutoScroll=true;

		this.AutoScrollMinSize=new Size(2000, 2000);

		this.Paint+=new PaintEventHandler(MyCustomControl_Paint);

	}
 

	//The paint method.

	private void MyCustomControl_Paint(object sender, PaintEventArgs e) {

		e.Graphics.FillRectangle(Brushes.Azure, 0, 0, 20, 50);

	}
 

}

Open in new window

0
Comment
Question by:Unimatrix_001
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Rahul Goel earned 500 total points
ID: 24755749

protected override void OnScroll(ScrollEventArgs se)

        {

            Invalidate(true);

        }

Open in new window

0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 24755801
Looks good. :) Next question:
http://www.experts-exchange.com/Q_24536910.html

Thanks,
Uni
0
 
LVL 3

Author Closing Comment

by:Unimatrix_001
ID: 31598815
:)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Email Body 4 46
How do I get the unique ID after insert? 87 89
What is MicroStrategy.NET? 2 44
.xltm file opens as .xlsx file 3 37
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now