C#用下拉框选择对象让pictureBox显示对象图片,其中用到ImageList控件存储图片
如何让下拉框选择哪个对象,pictureBox就显示相应的对象图片?效果图如下
这里用到了三个控件,comboBox1、pictureBox1和imageList1。话不多少,上代码!
comboBox1 && pictureBox1
//选择不同对象
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int index = comboBox1.SelectedIndex;
obType = index;
comboBox1.Text = comboBox1.Items[obType].ToString();
this.pictureBox1.Image = this.imageList1.Images[obType];
Console.WriteLine(comboBox1.Text);
}