-2

I have 31 numericipdowns (nup1,nup2,nup3....nup31), I want to add this numericupdowns values in datagridview.i used "For" loop and "switch", now i want to make something like this:

For(int i=1;i<32;i==){
   if(nup+i.value>0){
   dataGridView1.Rows.Add((nup+i).ToString(0)
   }
}

anybody can to help me?

1 Answers1

0
 for (int i = 1; i < 31; i++)
        {
            if (((NumericUpDown)this.Controls["nup" + i.ToString()]).Value > 0)
            {
                dataGridView1.Rows.Add(((Label)this.Controls["lbl" + i]).Text, ((NumericUpDown)this.Controls["nup" + i]).Value.ToString());
            }
}