[英]Bind a label in array of labels
I have an array of labels. 我有一系列标签。 I use these command lines to bind the Label's text to a column in my table, but it is not binding properly.
我使用这些命令行将Label的文本绑定到表中的列,但是绑定不正确。
Here is the applicable code: 这是适用的代码:
Label[] LL = new Label[26];
for (int i = 0; i < LL.Length; i++)
{
LL[i] = new Label();
LL[i].Text = null;
}
LL[0].DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.table_010_UserInfoBindingSource, "Column07", true));
You are only binding the first label in your array. 您仅绑定数组中的第一个标签。 Move the
LL[0].Databindings.Add...
line up into the for loop. 将
LL[0].Databindings.Add...
移动到for循环中。 Also, change the LL[0]
to LL[i]
or you will bind the same label over and over again. 另外,将
LL[0]
更改为LL[i]
否则您将一遍又一遍绑定相同的标签。
DataBinding语句需要在for
循环内
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.