Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
Detect Overlapping objects.
posted

Hi,

I am just taking my first steps in the .net world and am trying to find out a simple method of detecting if an object is overlapping another object.

for example in our app we want to change the text of an UltraLabel (right aligned text) based on some other values I have put the code in for this and also added code to check if the label would go off the left of the window and to then deal with this accordingly. The issue I am trying to overcom now is if there is another object to the left of a label and the label is then changed it could possible expand and then overlap the object to its left so need to find some simple method of detecting this so can stop the label extending over it.

Any suggestions gratefully received.

Regards.

  • 469350
    Offline posted

    This is a pretty simple matter of examining the Bounds of the control and then other controls on the form and seeing if any of the rectangle intersect.

    You could also use the Location and Size properties instead of Bounds, but Bounds would be easier, I think.

  • 69832
    Suggested Answer
    Offline posted

    You might want to consider using the Infragistics.Misc.UltraGridBagLayoutPanel control, which handles repositioning child controls based on available space.