【发布时间】:2013-01-30 13:53:15
【问题描述】:
我正在使用以下代码使用fileDialog 在我的一种表单中打开和显示图像:
private void btnExplorer_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "All files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
PictureBox PictureBox1 = new PictureBox();
PictureBox1.Image = new Bitmap(openFileDialog1.FileName);
// Add the new control to its parent's controls collection
this.Controls.Add(PictureBox1);
}
catch (Exception ex)
{
MessageBox.Show("Error loading image" + ex.Message);
}
}
}
问题是我的图像显示在表单的左上角,而我为此目的已经留下了几乎四分之一的右下角。我怎样才能在那里展示它?
【问题讨论】:
-
将图片框移动到表单的右下角?
-
以编程方式设置控件的位置:msdn.microsoft.com/en-us/library/tkzw7bw7.aspx
-
好的...这很合理,但我该怎么做呢?
标签: c# winforms visual-studio-2010