C # below ListView How to insert a picture _c# tutorial

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.