How to insert a picture in the ListView, I believe you want to know, the following for you to share the specific steps:
The first step: Drag the ListView control and the ImageList control in the form;
Step Two: set the images property of the ImageList control and add the picture you want;
Step Three: set the SmallImageList, LargeImageList, StateImageList property of the ListView control as ImageList;
Fourth Step: Edit the ImageIndex behavior of the ListView control item you will find that the picture has been successfully displayed!
Attached: Code to add options to the ListView control
private void Button1_Click (object sender, EventArgs e)
{
if (TextBox1.Text = = "")
{
MessageBox.Show (" The 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 to compare if there are duplicates, then discard the 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 the 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 = "";
}
}
}
The above is the entire content of this article, I hope this article will help you learn C # programming.