I am working on a projet with Microsoft VisualStudio Forms .NET 4.0 c#. I want to scroll on my forms page entirely, not on a precise object. I created a panel object called main_panel, which is the only child object of this (my forms page). It has a height of 1.6 times the client_size. I activated this.autoscroll = true. The problem is that when I shrank my window horizontally, the scroll bar allows me to scroll beyond my main_panel. When I resize in any other way, it works completly fine.
I checked :
- main_panel is the ONLY child object of this.
- the scroll is indeed beyond the main_panel's height, which is correctly defined.
- margins of main_panel and this are set to 0.
- this bug is happening on multiple computers
Here is a code I have written that reproduces this bug :
namespace My_forms
{
public partial class Test : Form
{
public Test()
{
InitializeComponent();
}
private void Test_Load(object sender, EventArgs e)
{
main_panel.BackColor = Color.Red;
main_panel.Location = new Point(0, 0);
this.Controls.Add(main_panel);
this.AutoScroll = true;
}
private void Test_SizeChanged(object sender, EventArgs e)
{
main_panel.Size = new Size((int)ClientSize.Width, (int)(ClientSize.Height * 1.6f));
//AutoScrollMinSize = main_panel.Size;
AdjustFormScrollbars(true);
Console.WriteLine(main_panel.Height);
}
}
}
If anyone has an idea on why this bug is occuring, I am interested, as this really looks like a bug from the autoscroll property, maybe in 4.0.