本文介绍了不增加tabindex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
foreach (string item in valueslist)
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();
TableCell col2 = new TableCell();
Label lb = new Label();
lb.Text = item;
TextBox tb1 = new TextBox();
tb1.Style["text-align"] = "Right";
tb1.ID = "txt" + k;
tb1.Text = "0";
tb1.EnableViewState = true;
tb1.AutoPostBack = true;
tb1.TextChanged += new EventHandler(tb1_TextChanged);
int cnt = 0;
tb1.ID = "Tab" + cnt.ToString();//Not incremented tabindex
tb1.TabIndex = (short)(cnt);
cnt++;
tb1.Text = "0";
string ids = string.Format("lb{0}", k);
lb.ID = ids;
tc.Controls.Add(lb);
col2.Controls.Add(tb1);
tr.Controls.Add(tc);
tr.Controls.Add(col2);
table.Controls.Add(tr);
k++;
}
推荐答案
int cnt = 0;
foreach (string item in valueslist)
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();
TableCell col2 = new TableCell();
Label lb = new Label();
lb.Text = item;
TextBox tb1 = new TextBox();
tb1.Style["text-align"] = "Right";
tb1.ID = "txt" + k;
tb1.Text = "0";
tb1.EnableViewState = true;
tb1.AutoPostBack = true;
tb1.TextChanged += new EventHandler(tb1_TextChanged);
tb1.ID = "Tab" + cnt.ToString();//Not incremented tabindex
tb1.TabIndex = (short)(cnt);
cnt++;
tb1.Text = "0";
string ids = string.Format("lb{0}", k);
lb.ID = ids;
tc.Controls.Add(lb);
col2.Controls.Add(tb1);
tr.Controls.Add(tc);
tr.Controls.Add(col2);
table.Controls.Add(tr);
k++;
}
问题是您的 cnt 变量.始终为0.
希望对您有帮助
The problem is your cnt variable. Always be 0.
Hope it helps
这篇关于不增加tabindex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!