0
我有我的资源嵌入在系统中,我搜索它们的字符串匹配图像的名称,但我仍然得到一个ArgumentNullException ...怎么回事?NullExceptionError当试图从资源加载图像
//Check if currencies are chosen
private void Action()
{
label1.Text = null;
//Checks if items are selected then what currencies are chosen
if (listBox1.SelectedIndex == -1 || listBox2.SelectedIndex == -1)
{
label1.Text = "Please select currencies";
}
else
{
LB1 = listBox1.SelectedItem.ToString();
LB2 = listBox2.SelectedItem.ToString();
Conversion();
}
pictureBox1.Image = Properties.Resources.ResourceManager.GetObject(LB1) as Image;
pictureBox2.Image = Properties.Resources.ResourceManager.GetObject(LB2) as Image;
}
非常感谢你提前!
'SelectedItem.ToString()'返回你期待的结果吗?我想你可能需要'SelectedValue'。 –
ToString方法似乎工作正常,我测试了它,它返回正确的值,所以当我按AUD返回一个字符串AUD ..这是一个非常奇怪的错误 –