关于从数据表获得标签的问题
我正在使用数据表存储和删除标签,因此我可以添加/remvove与清单项目状态相对应的标签。我能够在其中一列中成功存储并使用清单(我仅使用清单和一个行选择索引。这可以正常工作,但是我认为仅通过将某些标识符转换为一个清单选择,才能完成清单。字符串),但我无法弄清楚如何拉出标签并将其从表单中删除。我的(压缩)尝试以下结果结果是从标签应位于位置的零值。
myTable.Rows.Add(myCheckList, checklistIndex, myLabel);
...
DataRow[] myRows = myTable.Select(string.Format("Checklist = '{0}' AND Index = '{1}'", myCheckList, checklistIndex));
DataRow removeRow = myRows[0];
Label removeLabel = removeRow[2] as Label;
// removeLabel.Visible = false; this does not work and returns null
Controls.Remove(removeLabel);
我知道我会得到正确的行,因为我有一个数据视图网格链接到数据表。添加和删除行(未在代码样本中显示),如预期的那样,但我的标签不断恢复为null。
如何访问此标签并删除它?我无法以这种方式访问标签吗?
I am storing and removing labels with a data table, so I can add/remvove the labels that correspond to the state of checklist items. I am able successfully store and use a checklist within one of the columns (I am only using the checklist and an index for row selection. This works fine, however I think the checklist selection is only being done by converting some of the identifier into a string), but I can not figure out how to pull the label and remove it from the form. My (compressed) attempt as follow results in null being pulled from where a label should be.
myTable.Rows.Add(myCheckList, checklistIndex, myLabel);
...
DataRow[] myRows = myTable.Select(string.Format("Checklist = '{0}' AND Index = '{1}'", myCheckList, checklistIndex));
DataRow removeRow = myRows[0];
Label removeLabel = removeRow[2] as Label;
// removeLabel.Visible = false; this does not work and returns null
Controls.Remove(removeLabel);
I know I am getting the correct row because I have a data view grid linked to my data table. The rows are added and removed (not shown in code sample) as expected, but my label keeps coming back as null.
How can I access this label and remove it? Am I unable to access a label this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法存储并从数据表获得标签控件。它被转换为对象,不再被视为标签。
答案是存储标签名称。
I am unable to store and obtain a label control to and from a data table. It is converted to an object and is not considered a Label anymore.
The answer is to store label names instead.