获取控件相对于整个屏幕的位置? [英] Getting The Location Of A Control Relative To The Entire Screen?
问题描述
让我们说我有一个控制,它的位置是相对于它的父。如果它嵌入很多次,是...的主要形式的伟大伟大伟大的孙子,我怎么能确定它的位置是我的整个屏幕上,不只是它的直接父?这是通过打印的截图一个特定的控制(因为某些控件不要做DrawToBitmap不能正常工作)的目的。
Let's say I have a Control, it's location is relative to it's parent. If it's embedded many times and is ... the great great great grandchild of the main form, how can I determine what it's location is on my entire screen, not just it's immediate parent? This is for the purpose of printing a particular Control via a screenshot (since some controls don't do the DrawToBitmap doesn't work properly).
推荐答案
您正在寻找的<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.control.pointtoscreen.aspx\"><$c$c>PointToScreen$c$c>方法:
You're looking for the PointToScreen
method:
Point location = someControl.PointToScreen(Point.Empty);
这篇关于获取控件相对于整个屏幕的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!