如何使用滚动条设置固定大小的面板 [英] How to have a fixed size panel with scrollbar

查看:154
本文介绍了如何使用滚动条设置固定大小的面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我在Windows窗体上有一个500的固定大小的面板.如果我的背景图像大于面板尺寸,我希望滚动条出现.我该怎么做?

Currently, i have a fixed size panel of 500, 500 on a windows form. I want scrollbar to appear if my background image is bigger that the panel size. How can i do that?

推荐答案

[ ^ ]看起来像是一篇不错的文章如何在控件中放置滚动条.完成此操作后,您可以在其面板中放置一个大于其父面板的面板,并根据滚动条中的事件对其进行滚动.
This[^] looks like a good article on how to place a scrollbar in a control. Once you''ve done that, you can place a panel that''s bigger than it''s parent inside that panel, and scroll it based on events from your scrollbar.


set一些属性,例如.......
set some properties like.......
//you can set this properties at design time as well as runtime in constructor of class or in Form_Load event...
panel1.AutoScroll = true;

//set property of another control...
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;

//now change image runtime, you will see that your panel have a scrollbar if your image size is bigger than size of pictureBox control...



谢谢&问候
Punit Parmar



Thanks & Regards
Punit Parmar


尝试一下:
myPanel.AutoScroll = true;
Try this:
myPanel.AutoScroll = true;


这篇关于如何使用滚动条设置固定大小的面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆