Apologies for the really long code. My two buttons, taskpagebackbtn and taskpagenextbtn don't seem like they're being called. I set a message box and it didn't show up but I'm not sure why they are not being called, because when I open my form, when I click the buttons, they don't seem to work.
public partial class Task_Page : Form
{
TextBox[] subjectnamearray { get; set; }
List<string> datatablesubjectnamearray { get; set; }
int numofsubjects { get; set; }
public Task_Page(TextBox[] subjectnamearray, List<string> datatablesubjectnamearray, int numofsubjects)
{
InitializeComponent();
numoftasks.SelectedIndexChanged += (sender2, e2) => numoftasks_SelectedIndexChanged(sender2, e2,subjectnamearray, datatablesubjectnamearray, numofsubjects);
}
private void taskpagebackbtn_Click(object sender, EventArgs e)
{
this.Hide();
var SubjectPage = new SubjectPage();
SubjectPage.Closed += (s, args) => this.Close();
SubjectPage.Show();
SubjectPage.StartPosition = FormStartPosition.Manual;
SubjectPage.Location = new Point(this.Location.X, this.Location.Y);
}
private void taskpagenextbtn_Click(object sender, EventArgs e)
{
Marks_and_Weighting_Table marksandweightingtable = new Marks_and_Weighting_Table(subjectnamearray, datatablesubjectnamearray, numofsubjects);
foreach (Control control in this.Controls)
{
if (control is TextBox)
{
if (control.Text.Trim() == string.Empty)
{
MessageBox.Show("Please fill out all textboxes.", "Error Message");
/*https://www.codeproject.com/Questions/496674/EmptyplusTextboxplusValidationplusinplusC*/
return;
}
}
}
this.Hide();
var MarksandWeightingTable = new Marks_and_Weighting_Table(subjectnamearray, datatablesubjectnamearray, numofsubjects);
MarksandWeightingTable.Closed += (s, args) => this.Close();
MarksandWeightingTable.Show();
MarksandWeightingTable.StartPosition = FormStartPosition.Manual;
MarksandWeightingTable.Location = new Point(this.Location.X, this.Location.Y);
}
private void numoftasks_SelectedIndexChanged(object sender, EventArgs e, TextBox[] subjectnamearray, List<string> datatablesubjectnamearray, int numofsubjects)
{
lblsubjectname1.Text = subjectnamearray[0].Text;
lblsubjectname2.Text = subjectnamearray[1].Text;
lblsubjectname3.Text = subjectnamearray[2].Text;
lblsubjectname4.Text = subjectnamearray[3].Text;
lblsubjectname5.Text = subjectnamearray[4].Text;
lblsubjectname6.Text = subjectnamearray[5].Text;
/*https://stackoverflow.com/questions/2916684/c-sharp-net-change-label-text*/