Csharp中listview中自动加载imagelist中的本地图片

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace imagelist
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            LoadImageList();//窗体创建完毕自动加载到ListView
        }
        private void LoadImageList()
        {
            // Environment.CurrentDirectory
            //AppDomain.CurrentDomain.BaseDirectory
            //自动获取图片文件夹路径
            var path = AppDomain.CurrentDomain.BaseDirectory+ "/images/";
            var list = new List<string>();
            //图片命令格式,统一一下,可以是Png,jbg,bmp
            list.Add("01-01-0001.ico");
            list.Add("01-02-0002.ico");
            list.Add("01-03-0003.ico");
            list.Add("01-04-0004.ico");
            list.Add("01-05-0005.ico");
            list.Add("01-06-0006.ico");
            list.Add("01-07-0007.ico");
 
            ImageList imglist = new ImageList();
            imglist.ImageSize = new Size(48, 48);//设置图片显示大小
            imglist.ColorDepth = ColorDepth.Depth32Bit;//设置位图深度
            foreach (var fileName in list)
            {
                imglist.Images.Add(Image.FromFile(path + fileName));
                picListView.View = View.LargeIcon;//设置显示方式,前面设置了大小,可以省略
            }
            picListView.LargeImageList = imglist;
 
            for (int i = 0; i < imglist.Images.Count; i++)
            {
                var lvi = new ListViewItem();
                lvi.ImageIndex = i;
                lvi.Text = "P" + i;
                lvi.ToolTipText = "P" + i;
                picListView.Items.Add(lvi);//添加数据
            }
        }
    }
}

发布日期:

所属分类: 编程, 编程语言 标签:



Deprecated: 自 3.1.0 版本起,使用参数调用函数 WP_Query 已弃用caller_get_posts 已被废弃,请改用 ignore_sticky_posts。 in C:\xampp\htdocs\wp-includes\functions.php on line 6121

WordPress 数据库错误: [Unknown column 'wp_term_relationships.term_taxonomy_id' in 'where clause']
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_comments AS ct ON wp_posts.ID = ct.comment_post_ID AND ct.comment_type IN ('comment', '') AND ct.comment_parent=0 AND ct.comment_approved NOT IN ('spam', 'trash', 'post-trashed') WHERE 1=1 AND wp_posts.ID NOT IN (4318) AND ( wp_term_relationships.term_taxonomy_id IN (914) ) AND wp_posts.post_type = 'post' AND ((wp_posts.post_status = 'publish')) GROUP BY ct.comment_post_ID ORDER BY MAX(ct.comment_ID) DESC LIMIT 0, 4


Deprecated: 自 3.1.0 版本起,使用参数调用函数 WP_Query 已弃用caller_get_posts 已被废弃,请改用 ignore_sticky_posts。 in C:\xampp\htdocs\wp-includes\functions.php on line 6121

WordPress 数据库错误: [Unknown column 'wp_term_relationships.term_taxonomy_id' in 'where clause']
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_comments AS ct ON wp_posts.ID = ct.comment_post_ID AND ct.comment_type IN ('comment', '') AND ct.comment_parent=0 AND ct.comment_approved NOT IN ('spam', 'trash', 'post-trashed') WHERE 1=1 AND wp_posts.ID NOT IN (4318) AND ( wp_term_relationships.term_taxonomy_id IN (599,904) ) AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish'))) GROUP BY ct.comment_post_ID ORDER BY MAX(ct.comment_ID) DESC LIMIT 0, 4

没有相关文章!