Windowsフォームアプリケーションを作成しています。どのように私は窓のフォームのサイズをキャプチャするのですか?Windowsフォームのサイズを取得する
PictureBox display = new PictureBox();
display.Width = 360;
display.Height = 290;
this.Controls.Add(display);
display.Image = bmp;
しかし、私のディスプレイのサイズが特定の値にハードコードされている:
現在、私は私のコードでは、このようなものを持っています。
私は私がこのようなものを使用することができ、再サイズの正方形描きたい場合ことを知っている:
private Rectangle PlotArea;
private int offset = 30;
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
//// Calculate the location and size of the plot area
//// within which we want to draw the graphics:
Rectangle ChartArea = ClientRectangle;
PlotArea = new Rectangle(ChartArea.Location, ChartArea.Size);
PlotArea.Inflate(-offset, -offset);
Draw PlotArea:
g.DrawRectangle(Pens.Black, PlotArea);
}
を私は方法1を使用してのフォームのサイズをつかむための方法があります高さと幅?
私は、次のコードを試してみたが、それは動作しません...
PictureBox display = new PictureBox();
display.Width = ClientRectangle.Y;
display.Height = ClientRectangle.X;
this.Controls.Add(display);
display.Image = bmp;
ええと...私はこれを試しましたが、フォームがサイズ変更されているときにラインのサイズを変更しません... – BigBug
ありがとうございました!それは有用だった.. upvoted – BigBug