Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to search control location ( x , y ) in MDI child form . How to search it ???

What I have tried:

can find location in mdi parent
Posted
Updated 30-Nov-16 20:00pm

1 solution

Recursively follow the Controls collection, looking at each items Location:
C#
Control findLoc(ControlCollection controls, Point loc)
   {
   if (controls != null)
      {
      foreach (Control c in controls)
         {
         if (c.Location == loc)
            {
            return c;
            }
         Control f = findLoc(c.Controls, loc);
         if (f != null) return f;
         }
      }
   return null;
   }
Do note that the Location property is relative to the container, not the screen - so you may need to alter the target loc to allow for that when you recurse into it's Controls collection.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900