I suddenly wanted to use C # as an interface, but I never used C # as an interface. So let's take a look at the use of the control and lay the foundation for a tool.
Listview:
1. add an item to listview:
Listviewitem TMP = new listviewitem ("1111 ");
Listviewitem tmp1 = new listviewitem ("2222", 0 );
Listview1.items. Add (TMP );
Listview1.items. Add (tmp1 );
If you want to add an imagelist control for a graph, add an image, and set the largeimagelist attribute of listview to the newly added imagelist control, you can display the image.
2. Right-click the list menu:
Add a contextmenustrip control and set the contextmenistrip attribute of the listview control to the right-click menu control. However, if you click a blank area of the listview, the menu does not need to be displayed, add the following to the contextmenustrip opening method:
If (listview1.selecteditems. Count <= 0)
{
E. Cancel = true;
}
You can.
Treeview:
1. Add a node:
Treenode rootnode = new treenode (STR );
Treeview1.nodes. Add (rootnode );
Example:
Add the node from last Saturday to today, and use each day as a node.
Int COUNT = 0;
Datetime today = datetime. now;
Switch (today. dayofweek)
{
Case dayofweek. Saturday:
Count = 1;
Break;
Case dayofweek. Sunday:
Count = 2;
Break;
Case dayofweek. Monday:
Count = 3;
Break;
Case dayofweek. Tuesday:
Count = 4;
Break;
Case dayofweek. Wednesday:
Count = 5;
Break;
Case dayofweek. Thursday:
Count = 6;
Break;
Case dayofweek. Friday:
Count = 7;
Break;
}
Datetime today1 = datetime. now;
For (INT I = 0; I <count; I ++)
{
String [] Date = today1.adddays (-I). Date. tostring (). Split ('');
String STR = string. Format ("{0} {1}", date [0], today1.adddays (-I). dayofweek. tostring ());
Treenode rootnode = new treenode (STR );
Treeview1.nodes. Add (rootnode );
}