dimanche 27 août 2017

How to change value of textbox when a checkbox is selected C# winforms

I have 1 label and 4 checkboxes. What I want to do is when a checkbox is selected I want the price to increase or decrease in the textbox depending on if the checkbox was unchecked or not. I am lost on how I can do that.

label is TextBlock_Price

checkboxes are the following: phScreenRepair, virusRemoval, hardwareRepInstall, softwareInstall My code:

     public float? MultipleServiceAdder()
    {
        if (phScreenRepair.Checked)
        {
            return 20.00f;
        }
        if (virusRemoval.Checked)
        {
            return 10.00f;
        }
        if (hardwareRepInstall.Checked)
        {
            return 10.00f;
        }
        if (softwareInstall.Checked)
        {
            return 5.00f;
        }
        textBlock_Price.Text = "$0.00";
        return 0f;
    }




Aucun commentaire:

Enregistrer un commentaire