请教:TableLayoutPanel.Controls.Add中的下一个可行的单元位置(.net2.0,C#)

由于在新手区没有观众给意见,希望到精华区能找到帮助。谢谢。

运行环境:.net 2.0

AddAButtonIntoTable:

  private void button1_Click(object sender, EventArgs e)
        {
            Button b = new Button();
            b.Text = "new button" + (++index).ToString();
            tableLayoutPanel1.Controls.Add(b, (int)nColumn.Value, (int)nRow.Value);
        }
        int index = 0;

测试项目文件:/Files/zzj8704/TableLayoutTest.zip

初始状态:

问题:单击6次,出现如下结果,那位请解释为何结果如下.谢谢。

 

 

参考:

TableLayoutPanel1.Controls.Add(aButton,3,3);

Columns in a TableLayoutPanel are numbers starting at 1, while rows start at 0. Thus the
example shown above adds aButton to the cell in column 3 at row 3, which is actually the
fourth column and the fourth row the user sees. Note, however, that if a cell is already
occupied by a control, your control might not be added to that cell. Controls added to cells
at design time generally have precedence over controls added at run time. In these cases the
control is simply added to the next available cell. If you add the control to a cell that contains
another control that has been added at run time, the cell already in that position will usually
be moved down to the next available cell in favor of the control just added. As always, careful
testing is important.

 

转载于:https://www.cnblogs.com/zzj8704/archive/2009/06/14/1503103.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值