链接并行阵列和组合框时出现问题



我正在做一个班级作业,我正在尝试学习如何将我的并行数组链接到组合框选择。我的教科书没有我需要的信息,我希望这里有人能提供帮助。我的任务是建立一个显示税后净工资的工资单系统。我正在尝试设置它,以便用户从组合框中选择员工并按下按钮来计算净工资并显示结果以及您可能在薪水上看到的其他员工信息。当我运行程序并在做出选择后按下计算按钮时,没有任何反应。谁能告诉我为什么它不起作用?

用户界面外观的图片

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ZNSPayrollSystem
{
    public partial class ZNSPayrollSystem : Form
    {
        public ZNSPayrollSystem()
        {
            InitializeComponent();

            string[] arr = { "001 Peters", "002 Barnes", "003 Harris" };
            cboEmp.DataSource = arr.ToArray();

        }
        private void btnCalc_Click(object sender, EventArgs e)
        {
            //parallel arrays            
            int[] empID = { 001, 002, 003 };
            string[] empName = { "James Peters", "Sarah Barnes", "Jessica Harris" };
            double[] hrsWorked = { 40, 30, 45 };
            double[] empWage = { 55.50, 65.50, 75.70 };
            //declarations          
            double dblTaxRate = 8.2 / 100;
            double dblNetPay;
            double dblGrossPay;
            double dblTaxWithheld;
            int i = cboEmp.SelectedIndex;
            dblGrossPay = hrsWorked[i] * empWage[i];
            dblTaxWithheld = dblGrossPay * dblTaxRate;
            dblNetPay = dblGrossPay - dblTaxWithheld;
            txtEmpID.Text = empID[i].ToString();
            txtEmpName.Text = empName[i];
            txtHrsWork.Text = hrsWorked[i].ToString();
            txtWage.Text = empWage[i].ToString();
            txtGross.Text = dblGrossPay.ToString();
            txtTax.Text = dblTaxWithheld.ToString();
            txtNetPay.Text = dblNetPay.ToString();
        }
        private void btnClear_Click(object sender, EventArgs e)
        {
            txtEmpID.Text = "";
            txtEmpName.Text = "";
            txtHrsWork.Text = "";
            txtWage.Text = "";
            txtGross.Text = "";
            txtTax.Text = "";
            txtNetPay.Text = "";
        }
        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

点击按钮。然后在属性窗格中(右下角 屏幕默认(,点击"闪电"图标查看 事件。向下滚动并找到单击条目并确保它有 "btnCalc_Click"在那里。– Idle_Mind

@Idle_Mind 就是这样!!我简直不敢相信事情就这么简单?!非常感谢。- J.坎贝诺

最新更新