如何创建带有关闭、最大化和最小化按钮的 PictureBox?
我正在用 C# 创建一个 GUI。我打算使用 ListView 来查看图片预览,并使用 PictureBox
来显示完整视图。我使用 Panel
作为父级,并在其中放置一个 PictureBox
以使滚动条出现在图片框上。
我仍然不知道如何在 Panel
上提供关闭、最大化和最小化按钮,如许多 GUI 应用程序中所示。
我该怎么做?任何想法将不胜感激。
I am creating a GUI with C#. I intended to use a ListView to see preview of pictures, and a PictureBox
to display the full view. I used a Panel
as parent and placed a PictureBox
inside of that to have scrollbars appear on the picture box.
What I still can't figure out how to do is to provide close, maximize, and minimize, buttons on the Panel
, as seen in many GUI applications.
How can I do this? Any ideas will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那些其他 GUI 应用程序可能使用
Form
而不是Panel
/PictureBox
,假设它们提供最大化、最小化和关闭按钮。您可以将自己的按钮添加到
Panel
控件中,然后在其Click
事件处理程序中编写代码,以对该控件执行您想要的任何操作。如果您只想关闭图片,这很简单且相对直接,但复制所有内置于Form< 中的函数似乎是不必要的工作。 /代码>。
我会放弃
Panel
控件,向我的项目添加一个新的Form
,将现有的PictureBox
控件放置到我刚刚添加的表单上,然后从那里开始。您可能想要设置表单的FormBorderStyle
属性为“SizedToolWindow”之类的内容,具体取决于您希望它的外观。Those other GUI applications probably use a
Form
instead of aPanel
/PictureBox
, assuming that they provide maximize, minimize, and close buttons.You could add your own buttons to the
Panel
control, and then write code in theirClick
event handlers to do whatever you want with the control. This is easy and relatively straight-forward if you just want to be able to close the picture, but it seems like unnecessary work to duplicate all of the functions that are built right into aForm
.I'd ditch the
Panel
control, add a newForm
to my project, place the existingPictureBox
control onto the form that I just added, and go from there. You might want to set the form'sFormBorderStyle
property to something like "SizableToolWindow", depending on how you want it to look.