dynamic - C# dynamically change the value -
i pretty new @ c# , had make primitive neuron app. works pretty good, except values don't update dynamically.
the problem when change values in numericupdown
want current function(selected in combobox
) recalculate , change value in richtextbox
(the result box)
i sure it's event thing, couldn't find anywhere.
private void combobox1_selectedindexchanged(object sender, eventargs e) { if(combobox1.text=="suma") { decimal s = 0; decimal temp; (int = 0; < numericupdown1.value; i++) { var currentnumupdown = this.panel1.controls["numericupdown" + (100 + i).tostring()] numericupdown; var currentnumupdown2 = this.panel1.controls["numericupdown" + (200 + i).tostring()] numericupdown; temp = currentnumupdown.value * currentnumupdown2.value; s = s + temp; } richtextbox1.text = s.tostring(); fin = s; } if (combobox1.text == "produs") { decimal p = 1; decimal temp; (int = 0; < numericupdown1.value; i++) { var currentnumupdown = this.panel1.controls["numericupdown" + (100 + i).tostring()] numericupdown; var currentnumupdown2 = this.panel1.controls["numericupdown" + (200 + i).tostring()] numericupdown; temp = currentnumupdown.value * currentnumupdown2.value; p = p * temp; } richtextbox1.text = p.tostring(); fin = p; } if (combobox1.text == "minim") { decimal minim = 2; decimal temp; (int = 0; < numericupdown1.value; i++) { var currentnumupdown = this.panel1.controls["numericupdown" + (100 + i).tostring()] numericupdown; var currentnumupdown2 = this.panel1.controls["numericupdown" + (200 + i).tostring()] numericupdown; temp = currentnumupdown.value * currentnumupdown2.value; if (minim > temp) minim = temp; } richtextbox1.text = minim.tostring(); fin = minim; } if (combobox1.text == "maxim") { decimal maxim = -2; decimal temp; (int = 0; < numericupdown1.value; i++) { var currentnumupdown = this.panel1.controls["numericupdown" + (100 + i).tostring()] numericupdown; var currentnumupdown2 = this.panel1.controls["numericupdown" + (200 + i).tostring()] numericupdown; temp = currentnumupdown.value * currentnumupdown2.value; if (maxim < temp) maxim = temp; } richtextbox1.text = maxim.tostring(); fin = maxim; } }
i can provide more code if need it. thank in advance!
you need event numericupdown recalculate value.
try adding these events:
currentnumupdown.valuechanged += new eventhandler(combobox1_selectedindexchanged); currentnumupdown2.valuechanged += new eventhandler(combobox1_selectedindexchanged);
note object sender
, eventargs e
differ in method, depending on event called method.
Comments
Post a Comment