So, I was able to resolve this issue with the sgud clause.
The trick was to use the Rectangle.Intersect method inside the OnMouseUp event.
Here is the intuition I used behind her. (this may not be the best solution)
1) Create a list of all the controls inside my main panel.
2) Go through the controls and create a list of all the Rectangle Bounds for each control. you can get it by control.Bounds
3) Go to the Bounds list and cross it with the current active anchor of the element.
If the returned rectangle is the same height and width as the active control, then assign a change to the back color property.
I hope this helps anyone who has a similar problem.
Varun dave
source share