I try to explain my problem:
I got many customcontrols of same type on a panel.
At runtime I’m free to move any custumcontrol ( mousedown and mousemove events) in the form with mouse over any others customcontrols using bringtofront() to have it over all.
Now I need to know when the control I’m moving is over any other control and which control is under.
So far I’ve tryed to use drag-n-drop events but without success, there’s some other way to do this or I’ve to re elaborate it with drag events?
thank you all for help
and sorry for my English.
EDIT:
The controls are cards game and my final goal is to use cards to create logical sequence following rules based on card value and/or color.
You can’t solve the problem with drag-and-drop because you’re not actually dropping one control onto the other control. You’re merely moving them around in the form.
You need to become familiar with Z order, which is the front-to-back arrangement of objects in a virtual 3D space. To adjust the Z order, you can call the
BringToFrontandSendToBackmethods of any object that derives fromSystem.Windows.Forms.Control.The Z order is also exposed by the parent (container) control’s
Controlscollection. Using theGetChildIndexmethod, you can determine the position of any control within the Z order.So now, all you need to do is figure out which control the control you’re dragging is over. Do that by comparing the
Locationproperties of the two controls. When you know that the locations of two controls overlap, check their respective Z order indices to see which one is on top.