I have program which creates multiple NumericUpDowns depending on user input (1-5). I know how to get total value but how can I get value of each individual NumericUpDown. I was trying to test this using label1 but I get NullReferenceException error.
NumericUpDown test= new NumericUpDown();
test.Name = "mynum" + Convert.ToString(count2);
numericUpDown.Add(test);
System.Drawing.Point i = new System.Drawing.Point(8, 20+ i * 25);
test.Location = i;
test.Size = new System.Drawing.Size(50, 20);
this.Controls.Add(test);
test.ValueChanged += new EventHandler(mytotal);
NullReferenceException error is thrown at this line.
label1.Text = test.Controls["mynum0"].Text;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…