Original Post
Heya chaps! So I'm making this MDI editor. It's child forms should have scrollbars that are enabled always when needed. For the moment I try to load just an image in the forms and if the image's too big the scrollbars get enabled. The image gets loaded correctly. So to get these scrollbars showing I do: And SetupScrollbars() looks like: The scrollbars show correct, but the problem is I can't get their values to change. The Scroll event gets called and the scrollbars' values seem to increase at that point, but then get resetted back to zero :S What's going on? And what should I do? Thanks, MindWipe
private void RegionFile_Load(object sender, EventArgs e)
{
this.VerticalScroll.Visible = true;
this.HorizontalScroll.Visible = true;
SetupScrollbars();
}
{
int xOffset = (int)(regionImage.Width - ClientSize.Width;
int yOffset = (int)(regionImage.Height - ClientSize.Height;
if (xOffset > 0)
{
this.HorizontalScroll.Enabled = true;
this.HorizontalScroll.Maximum = xOffset;
this.HorizontalScroll.Minimum = 0;
this.HorizontalScroll.SmallChange = 1;
this.HorizontalScroll.LargeChange = xOffset / 4;
}
else
this.HorizontalScroll.Enabled = false;
if (yOffset > 0)
{
this.VerticalScroll.Enabled = true;
this.VerticalScroll.Maximum = yOffset;
this.VerticalScroll.Minimum = 0;
this.VerticalScroll.SmallChange = 1;
this.VerticalScroll.LargeChange = yOffset / 4;
}
else
this.VerticalScroll.Enabled = false;
}