C # control-listview entry application

Source: Internet
Author: User

I am still working as an intern, and I may need to use C # more in my future work. So during my internship, I took the initiative to learn C #.

I used to learn C ++, but I have learned a lot. I can use both Windows and Linux platforms. So it is not difficult to study C # Now. Due to limited time, I have learned a little about it.

After C #'s basic syntax, I started the windows programming. it is not very difficult to use other controls. You can simply check the information and use it. but in listview, because we still use the idea of MFC,

So I didn't get it out for half a day. Later I checked other people's video materials online to achieve the desired effect. Now I can basically use this control.

Drag the listview control to the dialog box, find the colums option in its attribute bar, and click the rightmost button.

See the following

Do not confuse name and text. Text is the header of the column to be displayed on the list control.

After completing each column of the control, add content to it.

Listview1.view = view. Details; // indicates the style of the control.
Student Stu = new student ();
Stu. sname = "Wang Wu ";
Stu. ssex = "male ";
Stu. snum = "200805678 ";
Stu. sgrade = "95"; // use a class to save information for each row
Listviewitem item = new listviewitem (New String [] {
Stu. sname, Stu. ssex, Stu. snum, Stu. sgrade}); // create each item
Item. Tag = Stu; // tag is used to save any type of data, so that you can conveniently call the data in the future.
This. listview1.items. Add (item); // add this item to the control.

Of course, if you select one or more rows, you want to view its details.

Foreach (listviewitem item in listview1.selecteditems)
{
Student Stu = (student) item. Tag;
MessageBox. Show (STU. sname );
}

Listview1.selecteditems indicates the set of all selected items, instead of a single item.

To sum up, listviewitem is very important. All information in each row is saved here.

 

 

 

 

 

 

 

 

 

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.