winform的panel加滚动条

1.在panel属性将AutoScroll属性设置为True

2.添加ControlAdded事件和Scroll事件

3.     private void panel3_Scroll(object sender, ScrollEventArgs e)
        {
            this.panel3.VerticalScroll.Value = e.NewValue;
            panel3.Invalidate();//刷新panel
        }

4. private void panel3_ControlAdded(object sender, ControlEventArgs e)
        {
            this.panel3.VerticalScroll.Enabled = true;
            this.panel3.VerticalScroll.Visible = true;
            this.panel3.Scroll += panel3_Scroll;
        }

猜你喜欢

转载自blog.csdn.net/yzy1970185464/article/details/82494235