screen position of control
-
hi, i am developing a WindowsApplication that when the user clicks on a ListViewItem a Form opens just on the position of the ListViewItem does any one know how is it possible to find out which point on the screen is the control location so i could tell the form where to open? The Control.Position property is not good enough since the control is in a few panels.... The MouseDown event is not good either since this action is accessible thru a context menu strip (which on this case the "MenuItem" may be lower than the ListViewItem)
-
hi, i am developing a WindowsApplication that when the user clicks on a ListViewItem a Form opens just on the position of the ListViewItem does any one know how is it possible to find out which point on the screen is the control location so i could tell the form where to open? The Control.Position property is not good enough since the control is in a few panels.... The MouseDown event is not good either since this action is accessible thru a context menu strip (which on this case the "MenuItem" may be lower than the ListViewItem)
Hi ... I am not sure if I understood you very well ... but what I understood is that you want to show a form where its upper left corner shall be in the upper left corner of a control on the form ... so it comes above it somehow ... anyway ... find the code below and I hope it helps:
Form2 frm = new Form2();
frm.StartPosition = FormStartPosition.Manual;
frm.Location = this.textBox1.PointToScreen(this.textBox1.ClientRectangle.Location);
frm.Show();This will place it exactly at the upper left corner of the control which including the titlebar ... in case you dont want to have the title bar to be it and the client region of the control use this instead:
Form2 frm = new Form2();
frm.StartPosition = FormStartPosition.Manual;
frm.Location = new Point (this.textBox1.X+this.Location.X,this.textBox1.Location.Y+this.Location.Y);
frm.Show();I hope this helps ...
Sincerely Samer Abu Rabie Note: Please remember to rate this post to help others whom reading it.