在运行时设置TabIndex属性

编程入门 行业动态 更新时间:2024-10-26 04:30:24
本文介绍了在运行时设置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属性

本文发布于:2023-06-10 22:50:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/620771.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   TabIndex

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!