I have a scrollable control I'm working on.
Some parts of the painting I want to always be in the same position
like my border. But when I hit the scroll bars my border moves. I
dont't understand why. Here's an example:
public class ListTable : System.Windows.Forms.ScrollableControl
{
public ListTable()
{
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
AutoScrollMinSize = new Size( 300, 300 );
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
//Draw Border
e.Graphics.DrawRectangle(Pens.Gray, 0,0, DisplayRectangle.Width-1,
DisplayRectangle.Height-1);
}
}
I thought this would keep the border in the same place since I am not
doing and translating and because the width/height of DisplayRectangle
never change.
But when I click on the scroll buttons my border moves around.
Why is this? What should I do? I do want some parts to scroll, just
not everything.