By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,558 Members | 1,533 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,558 IT Pros & Developers. It's quick & easy.

Flickering effect with panel scrollbars

P: 26
Hello all.

I have developed one user control "Grid" in C# and I am using it in another user control inside one panel.

The AutoScroll property for the panel is enabled.

When the height or width of "Grid" increases and becomes more than panel size, scrollbars of panel are enabled.

When I scroll using any scrollbar and click on the "Grid" which is inside panel, the position of the scrolled scrollbar changes automatically and scrollbars get reset to their original position.

To solve this problem, I saved the position of the scrollbars in the Panel_Scroll() event using

private void panel_Scroll(object sender, ScrollEventArgs e)
{
m_scrollPosition = panel.AutoScrollPosition; // m_scrollPosition is a Point
}

Now, I am setting this position again in the MouseDown event for the "Grid" like

private void Grid_MouseDown(object sender, MouseEventArgs e)
{
panel.AutoScrollPosition = new Point(Math.Abs(m_scrollPosition.X), Math.Abs(m_scrollPosition.Y));
}

this works fine, but I am getting the flickering effect.

I think this is because, when i am setting the "panel.AutoScrollPosition" in MouseDown event, the value of the "panel.AutoScrollPosition" is x = -3 & y = -3.

So scrollbars are getting reset and set again in flash and I am getting the flickering effect.

Is there any solution for this to avoid flickering effect?
Jan 12 '09 #1
Share this Question
Share on Google+
2 Replies


vekipeki
Expert 100+
P: 229
You can try using a ScrollableControl instead of Panel, I think it does not change the scroll position when it loses focus.
Jan 12 '09 #2

P: 26
Actually the user control is itself derived from ScrollableControl class. I checked it, but the problem is still there.
Jan 12 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.