?
Solved

Custom control not refreshing on scroll.

Posted on 2009-07-01
3
Medium Priority
?
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Rahul Goel ITIL earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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