c#如何在类中调用picturebox
我建了一个类和一个form,picturebox1在form中,我的类已经引用form了,为什么在类中写picturebox1还是显示不存在??类中的代码:publicv...
我建了一个类和一个form,picturebox1在form中,我的类已经引用form了,为什么在类中写picturebox1还是显示不存在??
类中的代码:
public void button1_Click()
{
OpenFileDialog ofdlg = new OpenFileDialog();
ofdlg.Filter = "Bmp File(*.bmp)|*.bmp";
if (ofdlg.ShowDialog() == DialogResult.OK)
{
Bitmap image = new Bitmap(ofdlg.FileName);
pictureBox1(报错).Image = image;
}
}
form中的代码:
private void button1_Click(object sender, EventArgs e)
{
Class1_1 ofdl = new Class1_1();
ofdl.button1_Click();
} 展开
类中的代码:
public void button1_Click()
{
OpenFileDialog ofdlg = new OpenFileDialog();
ofdlg.Filter = "Bmp File(*.bmp)|*.bmp";
if (ofdlg.ShowDialog() == DialogResult.OK)
{
Bitmap image = new Bitmap(ofdlg.FileName);
pictureBox1(报错).Image = image;
}
}
form中的代码:
private void button1_Click(object sender, EventArgs e)
{
Class1_1 ofdl = new Class1_1();
ofdl.button1_Click();
} 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询