I have a class called "student" which consists of a string "surname" and a string array "subjects". I also have a list of type "student" of all the students.
Expand|Select|Wrap|Line Numbers
- public class student
- {
- public static string surname;
- public string[] subjects = new string[10];
- };
- List<student> students = new List<student>();
Expand|Select|Wrap|Line Numbers
- private void button1_Click(object sender, EventArgs e)
- {
- ListViewItem lvi = new ListViewItem(textBox1.Text);
- lvi.SubItems.Add(subjects1);
- listView1.Items.Add(lvi);
- students.Add(new student
- {
- nazwisko = textBox1.Text,
- subjects1 = subjects
- });
- }
Expand|Select|Wrap|Line Numbers
- //upon clicking the remove button on a selected listview item
- if (listView1.SelectedItems.Count != 0)
- {
- foreach (ListViewItem lvi in listView1.SelectedItems)
- {
- lvi.Remove();
- }
- }