我一直在试图找出为什么当我的窗体运行,我使用下面的代码我的图像列表将不会呈现出我的图片...C#的ImageList也不会显示图像
public void renderImageList()
{
int selection = cboSelectedLeague.SelectedIndex;
League whichLeague = (League)frmMainMenu.allLeagues[selection];
string index = cboSelectedLeague.SelectedItem.ToString();
if (whichLeague.getLeagueName() == index)
{
foreach (Team t in allTeams)
{
Image teamIcon = Image.FromFile(@"../logos/" + t.getTeamLogo());
imgLstIcons.Images.Add(teamIcon);
}
}
else
{
MessageBox.Show("Something went wrong..." + whichLeague.getLeagueName() + " " + index + ".");
}
}
的方法是当用户更改我的组合框的索引时触发的,我知道该程序获得了正确的路径,因为我使用了一个消息框来显示每个路径按照我的预期返回的路径。
我是否错过了我的代码将图像绘制到框中?
Alex。
你不应该使用PictureBox吗? ImageLists不用于直接在表单上显示图像,而是用作其他控件使用的一包资源。 http://stackoverflow.com/a/8587685/1373170 – 2013-04-09 16:49:33
将图像绘制到哪个框?您可以从我所看到的内容中添加到“ImageList”中。这不显示图像... – MoonKnight 2013-04-09 16:49:35
啊好吧,imageList被设置为我的listView顶部的largeImage控件 - 我需要将他们绘制到listView? – Alex 2013-04-09 16:51:26