我有一个CheckBoxList,我正在填充数据.当我尝试从列表中检索已检查的项目时,我只能获取项目序号,我无法获得该值.
我已经读过你可以使用Items [i] .Value但是当我尝试这样做时,我得到一个错误,指出没有扩展方法'value'.
这是我用来尝试获取信息的代码(注意GetItemText(i)实际上只给我项目位置,而不是项目的文本)
private void btnGO_Click(object sender, EventArgs e)
{
for (int i = 0; i < chBoxListTables.Items.Count; i++)
{
if (chBoxListTables.GetItemChecked(i))
{
string str = chBoxListTables.GetItemText(i);
MessageBox.Show(str);
//next line invalid extension method
chBoxListTables.Items[i].value;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是使用.Net 4.0
任何想法将不胜感激...谢谢