textboxs aren't updating when I select a new option from combo box c# -


my code this:

if (combobox5.text == "primer") {     richtextbox5.text = "this number of primer tins" + primer.tostring(); } if (combobox3.text == "matt") {     richtextbox6.text = "this how many 2.5 tins of paint needed: " + val44.tostring(); } if (combobox3.text == "vinyl") {     richtextbox6.text = "this how many 2.5 tins of paint needed" + val55;     richtextbox3.text = valcm.tostring(); } if (combobox3.text =="silk") {     richtextbox3.text = valcostsilk.tostring(); } 

the code runs fine, when go select new option combo box doesn't update relevant rich text box. say, new , appreciated.

create clear function richtextboxes , call before string comparison

public void clearallrichtextboxes() {     richtextbox3.clear();     richtextbox5.clear();     richtextbox6.clear(); } 

your combobox_selectionchanged function should this

public void combobox_selectionchanged(object sender, selectionchangedeventargs e) {     clearallrichtextboxes();     if (combobox5.text == "primer")     {         richtextbox5.text = "this number of primer tins" + primer.tostring();     }     if (combobox3.text == "matt")     {         richtextbox6.text = "this how many 2.5 tins of paint needed: " +      val44.tostring();     }     if (combobox3.text == "vinyl")     {         richtextbox6.text = "this how many 2.5 tins of paint needed" + val55;         richtextbox3.text = valcm.tostring();     }     if (combobox3.text =="silk")     {         richtextbox3.text = valcostsilk.tostring();     } } 

Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -