1
我想提出一個方案來學習如何生成動態內對Button_Click事件循環控制,現在我試圖計算第三文本框兩個領域的乘法和它們的輸出計算在Windows窗體應用程序動態生成的控制
代碼:
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
unit.Location = new System.Drawing.Point(unitstartposition, unitstartpositionV);
unit.Size = new System.Drawing.Size(100, 30);
unit.Text = "";
unit.Name = "unit" + i.ToString();
rate.Location = new System.Drawing.Point(ratestartposition, ratestartpositionV);
unit.Size = new System.Drawing.Size(100, 30);
rate.Text = "";
rate.Name = "rate" + i.ToString();
amt.Location = new System.Drawing.Point(amtstartposition, amtstartpositionV);
amt.Size = new System.Drawing.Size(100, 30);
amt.Text = "";
amt.Name = "amt" + i.ToString();
panel1.Controls.Add(unit);
panel1.Controls.Add(rate);
panel1.Controls.Add(amt);
unitstartpositionV += 30;
ratestartpositionV += 30;
amtstartpositionV += 30;
unit = new TextBox();
rate = new TextBox();
amt = new TextBox();
}
現在我要計算它像
amt0.Text = (ConvertToInt32(unit0.Text) * ConvertToInt32(rate0.Text)).ToString();
amt1.Text = (ConvertToInt32(unit1.Text) * ConvertToInt32(rate1.Text)).ToString();
等
最後我想總結一下所有的(i)。請幫助實現這一點。