so I have a list where I have all my inputs, then to show them I'm using a propertyGrid. I want to have 2 buttons PREVIOUS and NEXT that I'll be using them to go through my property grid (list, actually) and its inputs. The code I used for that is this one:
private void btnStanga_Click(object sender, EventArgs e)
{
if (index < angajati.Count - 1)
{
index += 1;
propertyGrid1.SelectedObject = angajati[index];
}
}
private void btnDreapta_Click(object sender, EventArgs e)
{
if (index > 0)
{
index -= 1;
propertyGrid1.SelectedObject = angajati[index];
}
}
But it doesn't work the way I want to, in order for the buttons to have a reaction and do what I want, I need to press each of them like 3 times in a row :( What am I doing wrong?