ImageList控件

代码添加图片 
ImageList1.Images.Add(Image.FromFile("c:\\windows\\FeatherTexture.bmp"));

 

            //设置控件的排列样式

            listView1.View = View.Tile;

            //设置属性

            listView1.LargeImageList = imageList1;

            //手动添加图片或者用代码添加

            imageList1.Images.Add(Image.FromFile(@"F:\图片\Pictures\立体图片\Fish06.jpg"));

            imageList1.Images.Add(Image.FromFile(@"F:\360wallpaper_dt.jpg"));

            //向空间中添加项目

            listView1.Items.Add("张三");

            listView1.Items.Add("李四");

            listView1.Items.Add("王五");

            listView1.Items.Add("001");

            listView1.Items.Add("002");

            listView1.Items.Add("003");

       for (int i = 0; i <= 5; i++)

       {

        if (i < 3)

        {

            listView1.Items[i].ImageIndex = 0;

        }

        else

        {

            listView1.Items[i].ImageIndex = 1;

        }

       }

 

 //设置控件的排列样式

            //listView1.View = View.Tile;

            // listView1.View = View.List;

            listView1.View = View.SmallIcon;

            //设置属性

            listView1.LargeImageList = imageList1;

            ////手动添加图片或者用代码添加

            //imageList1.Images.Add(Image.FromFile(@"F:\图片\Pictures\立体图片\Fish06.jpg"));

            //imageList1.Images.Add(Image.FromFile(@"F:\360wallpaper_dt.jpg"));

            listView1.Groups.Add(new ListViewGroup("姓名",HorizontalAlignment.Left));

            listView1.Groups.Add(new ListViewGroup("编号",HorizontalAlignment.Left));

            //向空间中添加项目

            listView1.Items.Add("张三");

            listView1.Items.Add("李四");

            listView1.Items.Add("王五");

            listView1.Items.Add("001");

            listView1.Items.Add("002");

            listView1.Items.Add("003");

            //将listView1中索引为0、1、2的项添加到第一组

            listView1.Items[0].Group = listView1.Groups[0];

            listView1.Items[1].Group = listView1.Groups[0];

            listView1.Items[2].Group = listView1.Groups[0];

            //将listView1中索引为3、4、5的项添加到第二组

            listView1.Items[3].Group = listView1.Groups[1];

            listView1.Items[4].Group = listView1.Groups[1];

            listView1.Items[5].Group = listView1.Groups[1];

            //for (int i = 0; i <= 5; i++)

            //{

            //    if (i < 3)

            //    {

            //        listView1.Items[i].ImageIndex = 0;

            //    }

            //    else

            //    {

            //        listView1.Items[i].ImageIndex = 1;

            //    }

            //}

ImageList控件

 http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=ZH-CN&k=k(SYSTEM.WINDOWS.FORMS.IMAGELIST);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22);k(DevLang-CSHARP)&rd=true

你可能感兴趣的:(image)