WinForm Introduction to the usage of the ListView

Source: Internet
Author: User

 PublicForm1 () {InitializeComponent (); //the behavior of the controlListview1.bounds =NewRectangle (NewPoint (Ten,Ten),NewSize ( -, $));//relative PositionListview1.view = View.Details;//displays any number of columns, only the first column can contain iconsListview1.labeledit =true; Listview1.gridlines=true;//Show Gridlistview1.sorting = Sortorder.none;//Sort the content//Add ColumnsLISTVIEW1.COLUMNS.ADD ("name",-2, HorizontalAlignment.Left); LISTVIEW1.COLUMNS.ADD ("Sex", -2, HorizontalAlignment.Left); LISTVIEW1.COLUMNS.ADD ("Date of birth",-2, HorizontalAlignment.Left); LISTVIEW1.COLUMNS.ADD ("Age",-2, HorizontalAlignment.Center); //Create ItemListViewItem item1 =NewListViewItem (); Item1. Checked=true; Item1. Text="Wann"; Item1. SubItems.Add ("male"); Item1. SubItems.Add ("1975"); Item1. SubItems.Add (" +"); ListViewItem item2=NewListViewItem ("Liu Pingyun",1); Item2. Checked=false; Item2. SubItems.Add ("male"); Item2. SubItems.Add ("1947"); Item2. SubItems.Add (" -"); ListView1.Items.AddRange (Newlistviewitem[]{item1,item2}); }        Private voidButton1_Click (Objectsender, EventArgs e) {            //Add a ListView project dynamicallyListViewItem item =NewListViewItem (); Item. Text=TextBox1.Text; Item.            SubItems.Add (TextBox2.Text); Item.            SubItems.Add (TextBox3.Text); Item.            SubItems.Add (Textbox4.text); ListView1.Items.AddRange (NewListviewitem[]{item}); Textbox1.clear ();//clear the contents of the TextBox1textbox2.clear ();            Textbox3.clear ();        Textbox4.clear (); }        Private voidListview1_itemactivate (Objectsender, EventArgs e)//Select the ListView item{ListView LW=(ListView) sender; TextBox1.Text= LW. selecteditems[0]. subitems[0].            Text.tostring (); TextBox2.Text= LW. selecteditems[0]. subitems[1].            Text.tostring (); TextBox3.Text= LW. selecteditems[0]. subitems[2].            Text.tostring (); Textbox4.text= LW. selecteditems[0]. subitems[3].        Text.tostring (); }

WinForm Introduction to the usage of the ListView

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.