【问题标题】:How To check object Names In Loops [duplicate]如何检查循环中的对象名称[重复]
【发布时间】:2018-01-15 22:56:58
【问题描述】:

我有 31 个 numericipdowns (nup1,nup2,nup3....nup31),我想在 datagridview 中添加这个 numericupdowns 值。我使用了“For”循环和“switch”,现在我想做这样的事情:

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

谁能帮帮我?

【问题讨论】:

    标签: c#


    【解决方案1】:
     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());
                }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-15
      • 1970-01-01
      • 1970-01-01
      • 2014-11-24
      • 2012-05-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多