Summary of teacher scoring project
Create a SE employee class
1.1//Analyze the project first
* 01. I need to display information about three employees in a ListView control
* Then you can define a 3-length array to host the data you want to display
* 02. Through analysis, we will define such an array
* se[] emps=new se[3];
* 03. Write a method: Assign a value to each item in the array
* 04. Bind the data in the array to the ListView, without traversing to an item in the array,
* form a row in the ListView
Se[] Emps=new se[2];
1.2//write a method to insert data into an SE object array
Public void LoadData ()
{
Emps[0]=new SE ();
Emps[0].id = "001";
Emps[0]. Name = "Bruce Lee";
Emps[0]. age = 15;
EMPS[1] = new SE ();
Emps[1].id = "002";
EMPS[1]. Name = "Cheng Long";
EMPS[1]. age = 15;
}
1.3//write a method that binds the data in the array to the ListView to form a row
Public void Fromarraytolistview ()
{
foreach (SE emp in Emps)
{
Each iteration of an item in the array constitutes a row on the interface
ListViewItem lvitem=new ListViewItem (emp.id);
LVITEM.SUBITEMS.ADD (EMP. Name);
LVITEM.SUBITEMS.ADD (EMP. Age.tostring ());
LVITEM.SUBITEMS.ADD (EMP. Assess);
LVITEM.SUBITEMS.ADD (EMP. Score.tostring ());
LVSHOW.ITEMS.ADD (Lvitem);
}
}
1.4//Double click on the mouse event
private void Lvshow_doubleclick (object sender, EventArgs e)
{
Get the employee selected by the user
Double-click the list interface to bring up the selected employee's information
Frmscore frm=new Frmscore ();
Frm.myitem = Lvshow.selecteditems[0];
frm. Show ();
}
Public ListViewItem myitem;
private void Frmscore_load (object sender, EventArgs e)
{
Txtname.text=myitem. SUBITEMS[1]. Text;
Txtassess.text = myitem. SUBITEMS[3]. Text;
Txtscore.text = myitem. SUBITEMS[4]. Text;
}
1.5//Assign the value in the text box to the MyItem object
private void Btnok_click (object sender, EventArgs e)
{
myitem. SUBITEMS[1]. Text = txtName.Text;
myitem. SUBITEMS[3]. Text = Txtassess.text;
myitem. SUBITEMS[4]. Text = Txtscore.text;
}
Reference type passing ListView presentation data