Here is the code (just in case you don't like downloading):
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ScrollableControl_Bug
{
public partial class Form1 : Form
{
ScrollableControl scrl = new ScrollableControl();
public Form1()
{
InitializeComponent();
}
private void Form1\_Load(object sender, EventArgs e)
{
this.Controls.Add(scrl);
this.Resize += new EventHandler(Form1\_Resize);
scrl.Dock = DockStyle.Fill;
scrl.AutoScroll = false; // We want to draw the contents of "scrl" based on the scrollbar position. (No controls inside it)
scrl.Visible = true;
scrl.HorizontalScroll.Minimum = 0;
scrl.HorizontalScroll.Maximum = 400;
scrl.HorizontalScroll.LargeChange = this.Height;
scrl.HorizontalScroll.SmallChange = 10;
scrl.HorizontalScroll.Value = 30;
scrl.HorizontalScroll.Visible = true;
scrl.VerticalScroll.Minimum = 0;
scrl.VerticalScroll.Maximum = 400;
scrl.VerticalScroll.LargeChange = this.Width;
scrl.VerticalScroll.SmallChange = 10;
scrl.VerticalScroll.Value = 30;
scrl.VerticalScroll.Visible = true;
scrl.Scroll += new ScrollEventHandler(scrl\_Scroll);
scrl.Paint += new PaintEventHandler(scrl\_Paint);
}
void scrl\_Paint(object sender, PaintEventArgs e)
{
Graphics gr = e.Graphics;
string str = "Horiz. Scroll Value = " + scrl.HorizontalScroll.Value.ToString() +
"\\r\\nVert. Scroll Value = " + scrl.VerticalScroll.Value.ToString() +
"\\r\\n\\r\\nTry to scroll...";
gr.DrawString(str, new Font("Arial", 10.0f), new SolidBrush(Color.Black), 0.0f, 0.0f);
}
void Form1\_Resize(object sender, EventArgs e)
{
scrl.VerticalScroll.LargeChange = this.Height;
scrl.HorizontalScroll.LargeChange = this.Width;
scrl.Refresh();
}
void scrl\_Scroll(object sender, ScrollEventArgs e)
{
scrl.Refresh();
}
}
}
kostas KEL