private int i=0;
private void button1_Click(object sender, EventArgs e)
{
            PictureBox myPic = new PictureBox();
            myPic.Name = "pic" + i;
            this.Controls.Add(myPic);
}
在创建了N个PictureBox之后,我想获取第i=5的PictureBox的Name属性,怎么解决?

解决方案 »

  1.   

    不就是:"pic" + i。这也要问,囧。
      

  2.   

    创建:
           
    CheckBox[] name = new CheckBox[num];
    for (int i = 0; i < num; i++)
    {
         name[i] = new CheckBox();
         name[i].Text = fileName[i];
         name[i].Location = new Point(20, 10 + i * 25);
         name[i].Size = new Size(104, 16);
         name[i].Checked = false;
         pointStyleDlg.panel2.Controls.Add(name[i]);
    }获取:            foreach (Control c in this.splitContainer2.Panel1.Controls)
                {
                    if (c is CheckBox)//此处修改控件名称
                    {
                        if (((CheckBox)c).Checked)
                        {
                            fileds.Add(((CheckBox)c).Text.ToString());
                        }
                    }
                }
      

  3.   


    我中批号运行之后获取,比如说在
    private void button2_Click(object sender, EventArgs e)
    {
                //获取Name
      

  4.   

    我是指在运行之后获取,比如说在
    private void button2_Click(object sender, EventArgs e)
    {
                //获取第i=5的PictureBox的Name属性
      

  5.   


    不知所云~IPO是 Input -> Proess -> Output没Input处理个屁啊!!
      

  6.   

    PictureBox MyPic = (PictureBox)this.Controls.Find("pic5");   
      

  7.   

    foreach(Control ctrl in this.Controls)
      MessageBox.Show(ctrl.Name)