■66600 / ) |
Formのサイズを画像のサイズに合わせるには? |
□投稿者/ mako_chan3 (4回)-(2013/05/10(Fri) 15:41:16)
|
分類:[C#]
pictureBoxで画像を表示します。その際、pictureBoxとFormのサイズを画像のサイズに合わせることを考えています。 picuterBoxは合わせることができたのですが、Formのサイズを合わせることができません。
画像表示部分のコードを示します。
//画像を表示する if (openFileDialog1.ShowDialog() == DialogResult.OK) { Bitmap bmp = new Bitmap(openFileDialog1.FileName); pictureBox1.Width = bmp.Width; //画像の幅を取り込む pictureBox1.Height = bmp.Height; //画像の高さを取り込む if (this.Width < pictureBox1.Width + 10) //フォームサイズを画像サイズに合わせる this.Width = pictureBox1.Width + 10; if (this.Height < pictureBox1.Height + 10) this.Height = pictureBox1.Height + 10; pictureBox1.Image = bmp; }
よろしくお願いします。
|
|