#region 绑定ImageList图片
ImageList imalist = new ImageList();
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TreeView));
imalist = new ImageList();
//imalist.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imalist.ImageStream")));
imalist.TransparentColor = System.Drawing.Color.Transparent;
tv_UserGroup.ImageList = imalist;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//当前程序路径
string imgPaths = System.Windows.Forms.Application.StartupPath.Replace("\\bin", "").Replace("\\Debug", "");
List<string> list = new List<string>();
list.Add("\\ResourceMap\\PeopleAndBook.JPG");
list.Add("\\ResourceMap\\computer.JPG");
list.Add("\\ResourceMap\\computers.JPG");
list.Add("\\ResourceMap\\key.JPG");
list.Add("\\ResourceMap\\Peoples.JPG");
//ImageList序号
int imgIndex = 0;
//image物理名
string imgName;
foreach (string imgPath in list)
{
if (imgPath != string.Empty)
{
imgName = imgPath.Substring(imgPath.LastIndexOf("\\") + 1, imgPath.Length - imgPath.LastIndexOf("\\") - 1);
System.Drawing.Image myImage = System.Drawing.Image.FromFile(imgPaths + imgPath);
imalist.Images.Add(myImage);
imalist.Images.SetKeyName(imgIndex, imgName);
imgIndex++;
}
}
#endregion
这个是把图片绑定到imagelist上,然后用timer控件刷新就可以啦
温馨提示:内容为网友见解,仅供参考