簡體   English   中英

創建獨立於分辨率的winform,為C#winform設置分辨率,獲取winform運行的屏幕分辨率

[英]creating resolution independent winform,set resolution for C# winform, get the screen resolution on which the winform is running

我在1366x768分辨率上做了一個應用,這是我筆記本電腦目前的分辨率,作為一個初學者,我不關心分辨率問題。

當我拿到那個應用程序並在較低分辨率的PC上執行它時,一切都搞砸了。 表格在其他地方,其中大部分隱藏。

那么,請幫助我如何使我的winform分辨率獨立,或如何獲得當前的屏幕分辨率並將其設置為我的winform,以便相應地改變自己。

該物業

Screen.PrimaryScreen.WorkingArea

對於表單大小和定位非常有用。 例如這段代碼:

        this.Width = Screen.PrimaryScreen.WorkingArea.Width/2;
        this.Height = Screen.PrimaryScreen.WorkingArea.Height/2;
        this.Top = (Screen.PrimaryScreen.WorkingArea.Top + Screen.PrimaryScreen.WorkingArea.Height)/4;
        this.Left = (Screen.PrimaryScreen.WorkingArea.Left + Screen.PrimaryScreen.WorkingArea.Width)/4;

(Screen類是System.Windows.Forms命名空間的成員)

將它執行的表單放在屏幕中間,並將其大小調整為屏幕的一半。

WorkingArea var用於在計算屏幕大小時排除桌面上的任務欄和其他停靠項等內容。

希望這可以幫助。

請參閱: http//social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/1be40692-80fa-42ba-b316-9fe13a935b4f/ ,此處: http//social.msdn.microsoft.com/論壇/ EN-US /的WinForms /線程/ d5f2cd8d-d24d-4574-ba3a-96e22e3d1b56 /

一般方法是從您將要使用的最小分辨率開始。 然后你可以擴展你的表格(使用適當的對接和錨點)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM