110,536
社区成员
发帖
与我相关
我的任务
分享
public static class ListViewBind{
public static ImageList imageList = null;
// 获得ImageList
public static ImageList ImgListBind()
{
imageList = new ImageList();
imageList.ColorDepth = ColorDepth.Depth24Bit;
imageList.ImageSize = new Size(105, 105);
for (int i = 1; i <=11; i++)
{
imageList.Images.Add(Image.FromFile(Application.StartupPath + "\\" + (i).ToString() + ".jpg"));
string strName = imgNameArr[i-1].ToString();
}
return imageList;
}
public static ListView lv = null;
// 绑定ListView
public static ListView lvBind()
{
// 如果ImageList为空 则返回
if (ImgListBind() == null)
{
return null;
}
// 新建一个ListView
else
{
lv = new ListView();
lv.LargeImageList = ImgListBind();
for (int i = 1; i <= 11; i++)
{
lv.Items.Add(imgNameCNArr[i - 1].ToString());
lv.Items[i - 1].ImageIndex = i - 1;
}
return lv;
}
}
}
form_load
{
lvShape = BLL.ListViewBind.lvBind();
}