【发布时间】:2019-09-18 16:34:47
【问题描述】:
所以我有一个数组,其中包含订单表单上组合框的第一部分。组合框包含数据(x1、x2、x3、x4),并命名为 ketchupCount、mustardCount 等...
我想要做的是使用数组 normalCondoments 数组 + Count 来生成正确的组合框名称,将 SelectedIndex 值设置为未选中的 -1。最终它将获取值,而不是设置它,并将其打印到字符串...
预期的代码应该是 ketchupCount.SelectedIndex
string[] normalCondoments = { "ketchup", "mustard", "mayo", "ga",
"lettuce", "tomato", "pickles", "onion" };
foreach (var nCondoment in normalCondoments)
{
string str = nCondoment + "Count";
MessageBox.Show("letter:" + nCondoment);
str.SelectedIndex = -1;
}
我得到的错误是:
“字符串不包含 'SelectedIndex' 的选定定义,并且无法找到接受 'string' 类型的第一个参数的 'SelectedIndex' 的可访问扩展。”
VS 没有解决这个问题,我看了又看,但没有发现类似这个错误的东西。提前致谢
【问题讨论】:
-
什么是多选框?你指的是组合框吗?一个列表框?你能指定你正在使用的平台吗?您是否尝试将对象的引用与设置为其名称的字符串一起使用?
-
你指的是
<html:multibox>吗? -
我很抱歉它是组合框,在上面进行编辑以反映正确的术语
标签: c# string combobox selectedindexchanged assembly-references