0

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*/
Asereta
  • 1
  • 2
  • So ,are they [hooked up](http://stackoverflow.com/questions/33275763/copy-datagridview-values-to-textbox/33276161?s=14|0.0000#33276161) ? - Also: Did you try the [debugger](https://msdn.microsoft.com/en-us/library/y740d9d3.aspx), your very best friend in the world of coding. – TaW Jun 24 '18 at 12:56
  • What do you mean by hooked up? How would you use the debugger? – Asereta Jun 24 '18 at 12:57
  • Follow the link!! - In short it means that the event __name__, here `yourControl_theEvent` is __connected__ to the event. To do so one can __either use code__, like you would for dynamically created controls, maybe with lambda, __or__ one inserts it into the correct __slot of the events pane__ of the property tab. Select the Form, open the events pane (the one with the yellow flash) and locate (e.g.) the KeyDown event! Here insert the name of the event and you are done. – TaW Jun 24 '18 at 12:58
  • Where is the events pane? Nvm found it – Asereta Jun 24 '18 at 13:01
  • What am I suppose to do with this function? – Asereta Jun 24 '18 at 13:03
  • Which function?? The events pane list all event that are declared and connected to the control. Did you created the click events by double clicking the buttons or by pasting in the code? – TaW Jun 24 '18 at 13:09
  • Double clicking – Asereta Jun 24 '18 at 13:10
  • OK, then they ought to be hooked up and the debugger should hit the 1st lines when you set breakpoints there..? – TaW Jun 24 '18 at 13:11

0 Answers0