Question How to draw a rectangle above the child controls of the container and then to select

Jhon Smith

New member
Joined
Feb 6, 2014
Messages
3
Programming Experience
Beginner
Hi there!

I have a problem. My project have form with Panel control, which contain PictureBoxes. These PictureBoxes are created dynamically. I need to make ability to select PictureBoxes in standard way like in Windows Explorer: user hold the left mouse button and select a rectangular area. All PictureBoxes are caught in the area, will be selected.

The problem is I cannot draw a rectangle over the PictureBox, because it is included in a Panel container. I tried to solve the problem in two ways:
1) I put a transparent control over the Panel and draw a rectangle on it.
2) I use the drawing of a reversible frame on the ControlPaint.DrawReversibleFrame form.

The first method did not help me because if Panel has AutoScroll I was not able to select PictureBoxes outside the visible part of the Panel.

In the second method I found the sample code in MSDN. But the example code does not define the child elements of the parent Panel container, when the user draw a rectangle above the one.


Could you tell me please how to draw a rectangle above the child controls of the container and then to select the controls covered by the rectangle? Perhaps is there another way to solve this problem?

I would be glad of any information!
 
The example is for form mouse events and the form Controls. You should probably be handling the mouse events for your panel and its Controls.
 
No, the problem is not solved. The question is not handling control events, but what code to use to draw a rectangle above the child controls of the container and then to select
 
what code to use to draw a rectangle above the child controls of the container
DrawReversibleFrame method does that.
and then to select
The code example identifies each child control that intersects with the drawn rectangle. How you handle a control being "selected" is up to you.
 
Back
Top