很长的代码表示歉意。我的两个按钮taskpagebackbtn和taskpagenextbtn好像没有被调用。我设置了一个消息框,但它没有显示,但是我不确定为什么不调用它们,因为当我打开表单时,当我单击按钮时,它们似乎没有作用。
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*/