我想用一个N(可变的行数)二列的表格,第一行第一列里面放了一个TextBox1,第二列有一个Button,我想点击Button后触发事件  就是在表格的第二行第一列就会出现一个TextBox2,同时上一个Button就跳到第二行第二列,再点击Button后在表格的第三行第一列就会出现一个TextBox3,同时上一个Button就跳到第三行第二列,依次类推....   请问大虾们怎么实现,小弟想了几天了,请附上代码:万分感谢!!

解决方案 »

  1.   

    HtmlTable htb = Table名字;
    htb.Controls.Remove(Button控件名字);HtmlRow htr = new HtmlRow();
    HtmlCell htc1 = new HtmlCell();
    //Cell属性设置
    HtmlTextBox txtTextBox = new HtmlTextBox();
    //设置属性
    htc1.Controls.Add(txtTextBox);
    htr.Cells.Add(htc1);HtmlCell htc2 = new HtmlCell();
    //Cell属性设置
    HtmlButton btnButton = new HtmlButton();
    //设置属性
    htc2.Controls.Add(btnButton);
    htr.Cells.Add(htc2);htb.Rows.Add(htr)
      

  2.   

    就是呀,难就难在写触发事件上呀,同时我的触发事件的Button 也是动态跳转的呀,我很感谢一楼的兄弟,但是和我想的不完全一样!那位高手帮帮撒!!
      

  3.   

    private Button_OnClick(object sender, EventArgs e)
    {
       HtmlTable htb = Table名字;
       htb.Controls.Remove(Button控件名字);   HtmlRow htr = new HtmlRow();
       HtmlCell htc1 = new HtmlCell();
       //Cell属性设置
       HtmlTextBox txtTextBox = new HtmlTextBox();
       //设置属性
       htc1.Controls.Add(txtTextBox);
       htr.Cells.Add(htc1);  HtmlCell htc2 = new HtmlCell();
      //Cell属性设置
      HtmlButton btnButton = new HtmlButton();
      //设置属性
      btnButton.OnClick += new EventHandler(this.Button_OnClick); 
      htc2.Controls.Add(btnButton);
      htr.Cells.Add(htc2);  htb.Rows.Add(htr)
    }
      

  4.   

    其实你可以在上面加一行比在下面加要容易。点击button时在第一上面加一行只有TextBox,赋值为原来那个TextBox的值,再清空原来那个,那么你所有问题都解决了,因为从头到尾都只有一个button,不用动态对button加Click+=,而写代码的地方也没的你考虑了,只有一个地方。还有问题么?
      

  5.   

    而且,“看起来”跟你说的那种没有有区别。同样是button到了第2行,同样是第2行多了TextBox