Hi Manish,
Basically you need the following two steps:
1) Keep track of the last button index.
2) On 'next' click get the next button of the last button and process that (with background image or whatever).
1) Keeping track of the last button index is easy as they have names like Question1, Question2... etc.
You will need a global variable to keep track of that:
int LastButtonIndex;
Then change the
ButtonClickOneEvent
as follows. It is just taking a substring to obtain the button index.
void ButtonClickOneEvent(object sender, EventArgs e)
{
Button button = sender as Button;
button.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.button_Orange));
lblQuestionNo.Text = ((int)button.Tag).ToString() + ".";
LastButtonIndex = Convert.ToInt16(button.Name.Substring(8));
btnNext.Focus();
}
2) On 'next' click get the next button and process as required:
private void btnNext_Click(object sender, EventArgs e)
{
Control[] NextQuestion;
string ButtonName = "Question" + (LastButtonIndex + 1);
NextQuestion = Controls.Find(ButtonName, false);
if (NextQuestion.GetUpperBound(0) != -1)
(NextQuestion[0] as Button).BackColor = Color.Red;
}