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.