在运行时设置TabIndex属性 [英] Setting TabIndex property at runtime

查看:110
本文介绍了在运行时设置TabIndex属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们如何在运行时设置TabIndex?我有在运行时在其上创建PictureBox的WinForm.在窗体上,首先创建TableLayout,TableLayout中的每个单元格包含一个Panel,每个Panel包含一个Picture Box和Label.

我正在使用此代码创建上面的表格布局.

Hi,

How do we set the TabIndex at runtime? I have WinForm on which I am creating PictureBoxes at runtime. On the form, first the TableLayout is created, each cell in TableLayout contains a Panel, each Panel contains a Picture Box and a Label.

I am using this code to create the above Table Layout.

for (int col = 0; col <= tableLayoutPanel1.ColumnCount - 1; col++)
      {
        for (int rows = 0; rows <= tableLayoutPanel1.RowCount - 1; rows++)
        {
          tableLayoutPanel1.Controls.Clear();
          tableLayoutPanel1.RowCount = int.Parse(rowsTextBox.Text);
          tableLayoutPanel1.ColumnCount = int.Parse(columnsTextBox.Text);
          Panel p = new Panel();
          TextBox tb = new TextBox();
          PictureBox picb = new PictureBox();
          picb.BackColor = Color.White;
          p.Controls.Add(tb);
          p.Controls.Add(picb);
          picb.Location = new Point(0, tb.Top + 20);          
          picb.MouseLeave += PicbLSB;
          tableLayoutPanel1.Controls.Add(p, col, rows);          
        }
      }




我想设置PictureBoxes的TabIndex属性,从创建的第一个PictureBox开始为0,为最后创建的PictureBox为"last".
谢谢




I wanted to set the TabIndex property of the PictureBoxes starting 0 from the first PictureBox created and ''last'' for the last PictureBox created.
Thanks

推荐答案

为什么?
由于无法将图片框设置为选项卡,因此TabIndex是无关紧要的-请参见MSDN PictureBox.TabIndex属性 [^ ]
它甚至被遮盖了,所以您不能在设计时设置它!
Why?
Since a picture box cannot be tabbed to, the TabIndex is irrelevent - see MSDN PictureBox.TabIndex Property[^]
It is even masked so you can''t set it at design time!


这篇关于在运行时设置TabIndex属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆