C adds two methods to the picturebox control with the image selected state
- 2020-05-09 19:10:12
- OfStack
Method 1:
The easy way is to change the borderstyle style of the picturebox control
currentSelectPicBox.BorderStyle = BorderStyle.Fixed3D;
currentSelectPicBox Refresh(); // forces the control to redraw
Method 2
Add a rectangle to the picturebox control, , but this method is slow in the application.
How to add a rectangle:
Graphics pictureborder = currentSelectPicBox.CreateGraphics();
Pen pen = new Pen(Color.Red, 2);
pictureborder.DrawRectangle(pen, currentSelectPicBox.ClientRectangle.X, currentSelectPicBox.ClientRectangle.Y, currentSelectPicBox.ClientRectangle.X + currentSelectPicBox.ClientRectangle.Width, currentSelectPicBox.ClientRectangle.Y + currentSelectPicBox.ClientRectangle.Height);
Method to remove a rectangle
currentSelectPicBox.Invalidate();
If you have a better idea, please share with me