The cataloger wrote the program, wrote everything directly in the body of the event handlers. But the teacher cursed, said that everything should be beautiful, and said to remake using classes. He wants handlers to access classes. The delete button does not work, although the program is running. Please tell me what I'm doing wrong. Here is the code: The class itself
public static class Delete { public static void del() { ListBox listBox1 = new ListBox(); TextBox textBox1 = new TextBox(); listBox1.Items.Remove(listBox1.SelectedItem); textBox1.Text = ""; textBox1.Clear(); } } And here is the place where he goes to appeal
public void deleteButton_Click(object sender, EventArgs e) { // удаляет выбранный элемент из списка Delete.del(); }
delmethod? New ListBox and TextBox are created and something in them is cleared. - Anton Shchyrov