Don't bother using this.Controls
. The control that fired the event is already in sender
.
Try this in your "enter" and "leave" events:
var people_comboBox = sender as ComboBox;
With your current approach, peopleNum
is incremented each time you click the submitStudent
button. So if you click it 3 times, you're basically running this code every time:
ComboBox people_comboBox = this.Controls["people_comboBox2"] as ComboBox;