当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - How to create a checked listView with images

问题描述:

I want to create a listView that has in every row a checkBox, an image, and Text. I also want the rows presented like a listBox's, not like a grid(every item is below the predecessor item). So I tried this:

Imagelist.ImageSize = new Size(32, 32);

int count = 0;

listView1.LargeImageList = Imagelist;

listView1.CheckBoxes = true;

listView1.FullRowSelect = true;

List<string> names = new List<string>() { "1", "2", "3", "4" };

foreach (string s in names)

{

ListViewItem lst = new ListViewItem();

lst.Text = s;

lst.Tag = count;

lst.ImageIndex = count++;

lst.SubItems.Add(s);

listView1.Items.Add(lst);

}

But I have this presentation:

And when I add this line:

listView1.View = View.Tile;

I got this exception:

les cases à cocher (checkboxes) ne sont pas prises en charge en mode tile. choisissez un autre mode d'affichage ou définissez checkboxes à false.

this what i want:

网友答案:

thanks for you @terrybozzio, but i used an open source controle ObjectListView. and it's great.

分享给朋友:
您可能感兴趣的文章:
随机阅读: