2017-04-26 88 views
0

我接管了在.Net版本4上運行的Winforms應用程序的維護。啓動對象是登錄窗體。我有三臺顯示器。登錄表單以我的鼠標指針所在的任何監視器爲中心打開。我找不到表單中設置位置的任何代碼。我從來沒有見過這樣的表格。有沒有一種設置可以使這種情況發生,或者這只是正常的行爲?Winforms應用程序中的多個監視器和啓動對象的位置

回答

1

檢查窗體的StartPosition - 好像設置爲​​。
從MSDNs頁FormStartPosition枚舉:

Member name    Description 
CenterParent   The form is centered within the bounds of its parent form. 
CenterScreen   The form is centered on the current display, and has the dimensions specified in the form's size. 
Manual     The position of the form is determined by the Location property. 
WindowsDefaultBounds The form is positioned at the Windows default location and has the bounds determined by Windows default. 
WindowsDefaultLocation The form is positioned at the Windows default location and has the dimensions specified in the form's size. 

注意CenterScreen描述你描述的到底是什麼。

+0

謝謝。我把這個標記爲答案,因爲它確實回答了我的問題,但我發現它並非總是如此。 StartPosition設置爲CenterScreen的其他形式並非如此。這些表單將始終在主窗口中打開。我發現不同的是窗體的ShowInTaskbar屬性。設置爲True,表單在當前顯示中打開,如文檔所述。設置爲False並且表單總是在主顯示屏中打開。我會編輯你的答案以添加這條信息,但我似乎還沒有足夠的權限。 –