2009-09-06 9 views
13

C#を使用して読み込んだときに画面の右下にフォームを配置するにはどうすればよいですか?これは、(あなたがフォームデザイナでこれを設定することができます)あなたは、フォームの場所の値として設定するものは何でも、フォームの開始位置を設定しますWinFormをボトム右に配置

StartPosition = FormStartPosition.Manual; 

:あなたは

答えて

42

は、それはあなたのためにうまく機能ホープ

Rectangle workingArea = Screen.GetWorkingArea(this); 
this.Location = new Point(workingArea.Right - Size.Width, 
          workingArea.Bottom - Size.Height); 

の行に何かをしてみてください。

+0

優れています。ありがとう、私はこれを答えとして受け入れることができたらいいと思う:p –

0

コンストラクタを形成するには、次のコードを入れて。

+1

この通報は、誰もが異なるサイズのスクリーンを使用することで、それはあなたに罰金に見えるかもしれませんが、それはそれは顧客によるであろうと言うことではない... –

+0

1 - ええ、私はあなたがそのいずれかが必要だろうと思いますまた、フォームで指定した場所を使用するようにします。 –

10
Form2 a = new Form2(); 
a.StartPosition = FormStartPosition.Manual; 
a.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - a.Width, 
         Screen.PrimaryScreen.WorkingArea.Height - a.Height); 
0

これは私のために働いた。私はちょうどそれをしようとするのは簡単です、私のInitializeComponent();

public FormProgress() 
{ 
    InitializeComponent(); 
    Rectangle r = Screen.PrimaryScreen.WorkingArea; 
    this.StartPosition = FormStartPosition.Manual; 
    this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, Screen.PrimaryScreen.WorkingArea.Height - this.Height); 
} 
0

後に、下記のコードの3行を置きます。

//Get screen resolution 
Rectangle res = Screen.PrimaryScreen.Bounds; 

// Calculate location (etc. 1366 Width - form size...) 
this.Location = new Point(res.Width - Size.Width, res.Height - Size.Height);