如何使PictureBox可滚动[已改进] [英] How to Make a PictureBox Scrollable[Improved]

查看:101
本文介绍了如何使PictureBox可滚动[已改进]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:问题已得到改善.

大家好.

我有2个按钮,1个PictureBox和1个面板.
面板内部的PictureBox和面板的AutoScroll属性设置为"true".同样,PictureBox Dock属性设置为填充".

1.按钮将一个矩形绘制到pictureBox中,2.使矩形变大,其大小大于pictureBox本身.所以,我需要pictureBox可以滚动.

我该怎么做?这个线程有什么例子吗?

我最好的问候...

重要提示:请勿使用现有文件提供建议!我没有使用它们.

改进版本:

考虑到相同的情况:

假设当我们单击第二个按钮时,出现矩形和滚动条,并且它变得比图片框大,但它不会显示矩形的所有部分.我的意思是scroolbars不会动态变化,因此动态缩放的图像(较大的矩形)似乎无法正确显示.

Note: Question is improved.

Hey everyone.

I''ve 2 buttons, 1 PictureBox and 1 Panel.
PictureBox''s inside of the Panel and Panel''s AutoScroll property is set to "true". Also PictureBox Dock property is set to "Fill".

1. Button draws a Rectangle into the pictureBox, 2. one makes it bigger whose size is bigger than the pictureBox itself. So, I need pictureBox to be scrollable.

How can I make it? Any example for this thread?

My Best Regards...

Important: Please don''t give advise using existing files! I''m not using them.

Improved Version:

Considering the same situation:

Let''s say when we click the second button and the rectangle and scroll bars appeared and it becomes bigger than the picturebox, but it doesn''t show all the parts of the rectangle. I mean the scroolbars doesn''t change dynamically so the dynamically scaled image(bigger rectangle) can''t be seem properly.

How can I control set the scrollbars to control if image is bigger or not, so I can see the bigger rectangle?

推荐答案

将PictureBox的Dock属性设置为没有.如果将PictureBox设置为与面板一起调整大小,则滚动条无需变得可见.因此PB必须为静态大小,并且面板可以停靠在表单上.
Set the PictureBox''s Dock property to none. If the PictureBox is set to resize with the Panel, then scroll bars have no need to become visible. So the PB must be static size and the Panel can be Docked to the form.


也许您更改了诸如图片框大小之类的某些属性并且不对其进行更新.确保在面板上呼叫System.Windows.Forms.ScrollableControl.AdjustFormScrollbars.另外,检查所有其他AutoScroll...属性.


例如,您有Panel picturePanel,它是您PictureBox myPicture的父母.

Maybe you change some properties such as the Picture box size and do not update it. Make sure you''re calling System.Windows.Forms.ScrollableControl.AdjustFormScrollbars on your panel. Also, check up all other AutoScroll... properties.


For example, you have Panel picturePanel, and it is a parent of you PictureBox myPicture.

Panel picturePanel; 
PictureBox myPicture; //child of picturePanel

//...

myPicture.ClientSize = new Size(xSize, ySize); //changed
myPicture.Image = (Image)MyImage; //changes
//any change which potentially breaks the scroll position

//needs immediate fix:
picturePanel.AdjustFormScrollbars();



—SA



—SA


这篇关于如何使PictureBox可滚动[已改进]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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