简体   繁体   中英

How can I create a PictureBox with close, maximize, and minimize buttons?

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.

Those other GUI applications probably use a Form instead of a Panel / 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 their Click 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 a Form .

I'd ditch the Panel control, add a new Form to my project, place the existing PictureBox control onto the form that I just added, and go from there. You might want to set the form's FormBorderStyle property to something like "SizableToolWindow", depending on how you want it to look.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM