0

调试时出现此错误:“方法'STUDENTCOURSEDETAILS_Load'没有重载需要'0'参数”

STUDENTCOURSEDETAILS 是 Winform,STUDENTCOURSEDETAILS_Load 是表单的 OnLoad 事件。我试图在另一个函数中调用此事件并得到上述错误。如何在另一个函数中调用事件?如何在调用此事件时传递参数?我不知道我必须传递什么样的参数。需要帮忙...

private void STUDENTCOURSEDETAILS_Load(object sender, EventArgs e)
        {
            txtregno.Enabled        = false;
            txtstudentname.Enabled  = false;
            txtcoursid.Enabled      = false;
            txtcoursname.Enabled    = false;
            dtpdoj.Enabled          = false;
            txtfee.Enabled          = false;
            txtdiscountper.Enabled  = false;
            txtnarration.Enabled    = false;
            btnSave.Text            = "&Add";

        }

private void btnAdd_Click(object sender, EventArgs e)
        {
            switch (btnSave.Text)
            {
                case "&Add":
                    txtregno.Enabled        = true;
                    txtstudentname.Enabled  = true;
                    txtcoursid.Enabled      = true;
                    txtcoursname.Enabled    = true;
                    dtpdoj.Enabled          = true;
                    txtfee.Enabled          = true;
                    txtdiscountper.Enabled  = true;
                    txtnarration.Enabled    = true;
                    btnSave.Text            = "&Save";
                    break;
                case "&Save":
                    if (validation())
                    {
                        if (MessageBox.Show("sure to save?", CPublic.messagename, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            selectstudentid();
                            cmd.Connection = CPublic.Comm_con;
                            cmd.Parameters.Clear();
                            cmd.Parameters.AddWithValue("@regno", txtregno.Text);
                            cmd.Parameters.AddWithValue("@studentid", id);
                            cmd.Parameters.AddWithValue("@studentname", txtstudentname.Text);
                            cmd.Parameters.AddWithValue("@courseid", txtcoursid.Text);
                            cmd.Parameters.AddWithValue("@coursename", txtcoursname.Text);
                            cmd.Parameters.AddWithValue("@doj", dtpdoj.Value.ToString(CGeneral.ServeDateFmt));
                            cmd.Parameters.AddWithValue("@fee", txtfee.Text);
                            cmd.Parameters.AddWithValue("@discount", txtdiscountper.Text);
                            cmd.Parameters.AddWithValue("@narration", txtnarration.Text);
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.CommandText = "SP_INSERT_studentcoursedetails" + CPublic.g_firmcode;
                            cmd.ExecuteNonQuery();
                            MessageBox.Show("COURSE ADDED SUCCESSFULLY...", CPublic.messagename, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            clearall();
                            btnSave.Enabled         = true;
                            btnSave.Text            = "&Add";
                            STUDENTCOURSEDETAILS_Load();
                         }
                    }
                            break;
            }
        }
4

2 回答 2

3

那是因为线

btnSave.Text            = "&Add";
STUDENTCOURSEDETAILS_Load();

你应该使用

STUDENTCOURSEDETAILS_Load(null, null);

显然,您在运行时可能会遇到进一步的错误。

于 2013-08-16T06:30:19.163 回答
1

您可以像这样调用该方法:

STUDENTCOURSEDETAILS_Load(null, null);
于 2013-08-16T06:30:34.993 回答