怎样用Checked属性值或CheckState属性值的改变去处理
可以参考一下
using System;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public int PeanutPrice => chkPeanut.Checked ? 5 : default;
public int MelonSeedPrice => chkMelonSeed.Checked ? 7 : default;
public int BeerPrice => chkBeer.Checked ? 4 : default;
public int HamSausagePrice => chkHamSausage.Checked ? 2 : default;
public Form1()
{
InitializeComponent();
}
private void btnCalculate_Click(object sender, EventArgs e)
{
txtTotalPrice.Text = (PeanutPrice + MelonSeedPrice + BeerPrice + HamSausagePrice).ToString();
}
}
}
请问PeanutPrice这些是用的标签吗?