Can I calculate the location of a widget relative to the form on which it lies?

  • Thread starter Thread starter steve bull
  • Start date Start date
S

steve bull

I have a picture box which lies on a panel which lies on a form. Is there some way that I can calculate the position of
the picture box relative to the form rather than the panel on which it lies? The location of the picture box in the
Control class is given relative to the panel on which it lies.


Thanks,

Steve
 
There might be a better way to do this, but one way is to convert the child
controls location into screen coordinates and then convert that point back
to client coordinates using the Form. Something like the code below, where
"this" is a reference to the Form.

Point p =
this.PointToClient(this.panel1.PointToScreen(this.pictureBox1.Location));

--
Tim Wilson
..Net Compact Framework MVP

steve bull said:
I have a picture box which lies on a panel which lies on a form. Is there
some way that I can calculate the position of
the picture box relative to the form rather than the panel on which it
lies? The location of the picture box in the
 
Back
Top