This article mainly describes the C # implementation in the ListView Insert Picture Instance Code of the relevant information, the need for friends can refer to the following
C # Implementation Inserts the picture instance code in the ListView
First step: Drag the ListView control and the ImageList control into the form;
The second step: Set the images property of the ImageList control, add the picture you want;
Step three: Set the SmallImageList, LargeImageList, and StateImageList properties of the ListView control to ImageList;
Fourth step: Edit the ImageIndex behavior of the ListView control item you will find that the picture is displayed successfully!
Attached: Code to add an option to the ListView control
private void Button1_Click (object sender, EventArgs e) {if (TextBox1.Text = = "") {MessageBox.Show ("added content cannot be empty"); Textbox1.focus (); Get Focus} else {if (ListView1.Items.Count > 0)//Determine if there is an item in the list box {//Loop compare if there are duplicates, or discard add Add for (int i = 0; i < ListView1.Items.Count; i++) {if (String.Compare (listview1.items[i). Text.tostring (), textbox1.text) = = 0) {MessageBox.Show ("item duplicates, cannot be added! "); TextBox1.Text = ""; Empty text box Textbox1.focus (); Return }} listView1.Items.Add (TextBox1.Text.ToString ()); TextBox1.Text = ""; } else {ListView1.Items.Add (textBox1.Text.ToString ());//Add the data in the text box to the list box TextBox1.Text = " "; } } }