Snippets has posted 5883 posts at DZone. View Full User Profile
For example for control Label1:
private Point findCoords2(Control c)
// Recurse through all parent controls...
Point coord = new Point();
// Own location inside control
coord = c.Location;
// Add parents control coord (There is always at least one parent! ... if this isn't the Form...)
while (c.Parent != null)
c = c.Parent;
coord.X += c.Location.X;
coord.Y += c.Location.Y;
// Add pixel borders
coord.X += c.Margin.Left + 1;
// 23 for "classic" Windows look
// 30 for Windows XP standard look
//coord.Y += 30;
// Or try this...
coord.Y += c.Bounds.Height - c.ClientSize.Height - (c.Margin.Top + 1);
DZone's 170th Refcard is an essential reference to Camel, an open-source, lightweight, integration library. This Refcard is authored by...