如何在listview中插入图片,相信大家很想知道,下面就为大家分享具体步骤:
第一步:在窗体中拖入ListView控件和imageList控件;
第二步:设置imageList控件的Images属性,添加你想要的图片;
第三步:设置ListView控件的SmallImageList、LargeImageList、StateImageList属性为imageList;
第四步:编辑ListView控件项的ImageIndex行为你就会发现图片成功显示出来了!
附:在ListView控件中添加选项的代码
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("添加的内容不能为空"); textBox1.Focus(); //获取焦点 } else { if (listView1.Items.Count > 0) //判断列表框中是否有项 { //循环比较是否有重复项,有则放弃添加 for (int i = 0; i < listView1.Items.Count; i++) { if (string.Compare(listView1.Items[i].Text.ToString(), textBox1.Text) == 0) { MessageBox.Show("项目重复,不能添加!"); textBox1.Text = ""; //清空文本框 textBox1.Focus(); return; } } listView1.Items.Add(textBox1.Text.ToString()); textBox1.Text = ""; } else { listView1.Items.Add(textBox1.Text.ToString()); //将文本框中的数据添加到列表框 textBox1.Text = ""; } } }
以上就是本文的全部内容,希望本文所述对大家学习C#程序设计有所帮助。
最后
以上就是单薄路灯最近收集整理的关于C#下listview如何插入图片的全部内容,更多相关C#下listview如何插入图片内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复