我想在列表框中显示所有类型的控件(不重复)。我可以使用LINQ来获取我的表单中的各种控件吗?
我尝试这样做:
var controls = from c in this.Controls
select c;
foreach (var x in controls)
{
StringBuilder sb = new StringBuilder();
sb.Append(x);
listBox1.Items.Add(sb.ToString());
}
它不工作。 :(
编辑:
Error: Could not find an implementation of the query pattern for source type 'System.Windows.Forms.Control.ControlCollection'.
'Select' not found. Consider explicitly specifying the type of the range variable
什么不工作?有没有错误? – RPM1984 2010-11-11 05:12:39
here:'无法找到源类型'System.Windows.Forms.Control.ControlCollection'的查询模式的实现。 '选择'未找到。考虑明确指定范围变量的类型“ – yonan2236 2010-11-11 05:14:35