private void subjectpagenextbtn_Click(object sender, EventArgs e)
{
TextBox[] subjectnamearray = new TextBox[] { subjectname1, subjectname2, subjectname3, subjectname4, subjectname5, subjectname6 };
int i = 0;
while (i <= numofsubjects.SelectedIndex)
{
if (subjectnamearray[i].Text.Trim() == string.Empty)
{
MessageBox.Show("Please fill out all textboxes.", "Error Message");
i = i + 1;
return;
}
}
i = 0;
string[] subjects = new string[numofsubjects.SelectedIndex];
List<string> datatablesubjectnamearray = new List<string>();
this.Hide();
var TaskPage = new Task_Page(subjectnamearray,datatablesubjectnamearray,numofsubjects.SelectedIndex);
TaskPage.Closed += (s, args) => this.Close();
TaskPage.Show();
TaskPage.StartPosition = FormStartPosition.Manual;
TaskPage.Location = new Point(this.Location.X, this.Location.Y);
while (i < numofsubjects.SelectedIndex)
{
datatablesubjectnamearray.Add(subjectnamearray[i] + "Weighting");
datatablesubjectnamearray.Add(subjectnamearray[i] + "Marks");
/*http://csharp.net-informations.com/collection/list.htm*/
i = i + 1;
}
Task_Page taskpage = new Task_Page(subjectnamearray, datatablesubjectnamearray, numofsubjects.SelectedIndex);
}
This is the code for one of my buttons on a form that I have that collects the subjects of the users and number of subjects for users and I basically also made an array for the titles for the datatable that I'm going to create on the next form. I'm also passing the values,subjectnamearray, datatablesubjectnamearray, numofsubjects.SelectedIndex to TaskPage. So, Task Page is the page that I want to get to when I click the button. I also want these values to be passed but when I click on the button, it just freezes and I can't even close the application. I have to press the stop button on visual studio. But I don't know why it's freezing.