Flickering effect with panel scrollbars

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kulabhishek
    New Member
    • Dec 2008
    • 26

    Flickering effect with panel scrollbars

    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(ob ject sender, ScrollEventArgs e)
    {
    m_scrollPositio n = panel.AutoScrol lPosition; // m_scrollPositio n 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.AutoScrol lPosition = new Point(Math.Abs( m_scrollPositio n.X), Math.Abs(m_scro llPosition.Y));
    }

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

    I think this is because, when i am setting the "panel.AutoScro llPosition" in MouseDown event, the value of the "panel.AutoScro llPosition" 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?
  • vekipeki
    Recognized Expert New Member
    • Nov 2007
    • 229

    #2
    You can try using a ScrollableContr ol instead of Panel, I think it does not change the scroll position when it loses focus.

    Comment

    • kulabhishek
      New Member
      • Dec 2008
      • 26

      #3
      Actually the user control is itself derived from ScrollableContr ol class. I checked it, but the problem is still there.

      Comment

      Working...