TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aidan Follestad
NA
4
6.9k
C# - Graphics on custom panel control is distorted (smeared) when auto scrolled
Jan 30 2011 2:07 AM
Hello,
I have a custom panel control I'm using to make a contact list, and everything works perfectly except one thing:
I set autoscroll to true, and then have the AutoScrollMinSize property set to the number of items times the item height to get how much space all items will take up in points; that works, except once the user drags the scrollbar up or down, the graphics in the panel become distored and it appears that someone smeared paint all over the control.
Any ideas? I already have the OptimizedDoubleBuffer and ResizeRedraw styles set, that helps with when the user resizes the form containing the control, but it doesn't fix the panel graphics distortion issue.
*EDIT:
I found a solution; in the OnPaint override method, before you begin to draw to the panel graphics, you add this code:
e.Graphics.Transform = new Matrix(1, 0, 0, 1, this.AutoScrollPosition.X, this.AutoScrollPosition.Y);
This maintains the scroll position during painting, and allows smooth scrolling with autoscroll enabled.
Reply
Answers (
1
)
Need help on a calculator I'm making.
Splitting values in a combobox