partial class Form1
{
//hidden
private void InitializeComponent()
{
this.picture = new System.Windows.Forms.PictureBox();
//hidden
this.picture.Size = new System.Drawing.Size(1, 1);
//hidden
}
#endregion
private System.Windows.Forms.PictureBox picture;
private System.Windows.Forms.Button btnLoad;
private System.Windows.Forms.OpenFileDialog dgOpenFile;
private System.Windows.Forms.Panel panel1;
}
---
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnLoad_Click(object sender, EventArgs e)
{
if (dgOpenFile.ShowDialog() == DialogResult.OK)
{
Bitmap img = new Bitmap(dgOpenFile.FileName);
picture.Width = img.Width;
picture.Height = img.Height;
picture.Image = img;
}
}
}
Почему размер PictureBox
остается (1, 1) и не изменяется в размере изображения?