本文介绍了Winform面板可滚动大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Win10上使用VS2015 / C#测试面板控件:



在面板1中添加50个PictureBox控件:



Image img = Image.FromFile(Application.StartupPath + @\ .png); //任何形象



panel1.AutoScroll = true;

panel1.Height = 500;


i = 0; i< 50; i ++)

{

PictureBox pb = new PictureBox();

pb.Left = i * 10;

pb.Top = i *(img.Height + 10);

pb.SizeMode = PictureBoxSizeMode.AutoSize;

pb.Image = img;

toolTip1.SetToolTip(pb,i.ToString()+:+ pb.Top.ToString());

panel1.Controls.Add(pb);

}



如果图片框的顶部小于32767,图片框可以放在正确的位置。但是如果图片框的顶部大于32767,则图片框不能放置在正确的位置,它将被放置在面板的底部。换句话说,Panel控件的最大可滚动高度就像32767.



我希望所有图片框都在面板中的所需位置。是否有任何方法可以放大面板的可滚动尺寸?



我尝试过:



此问题存在于Win7 / 8/10上,但在WinXP中找不到。它与VS版本和.NET框架版本无关,只与Windows版本有关。

I use VS2015/C# on Win10 to test Panel control:

Add 50 PictureBox controls into panel1:

Image img = Image.FromFile(Application.StartupPath + @"\1.png"); //any image

panel1.AutoScroll = true;
panel1.Height = 500;

for (int i = 0; i < 50; i++)
{
PictureBox pb = new PictureBox();
pb.Left = i*10;
pb.Top = i * (img.Height + 10);
pb.SizeMode = PictureBoxSizeMode.AutoSize;
pb.Image = img;
toolTip1.SetToolTip(pb, i.ToString()+": "+pb.Top.ToString());
panel1.Controls.Add(pb);
}

If the 'Top' of a picture box is less than 32767, the picture box can be placed in right position. But if the 'Top' of a picture box is greater than 32767, the picture box can not be placed in right position, it will be placed at the bottom of the panel. In an another word, the maximum scrollable height of Panel control is like 32767.

I want all picture box in wanted position in panel. Is any method to enlarge panel scrollable size?

What I have tried:

This issue is exist on Win7/8/10, but no found in WinXP. It is no relation with VS versions and .NET framework versions, just in relation with Windows versions.

推荐答案


这篇关于Winform面板可滚动大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 02:06