名称"ListView1"在当前上下文中不存在 [英] The name 'ListView1' does not exist in the current context
本文介绍了名称"ListView1"在当前上下文中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void ListView1_Click(object sender, EventArgs e)
{
int cds = ListView1.SelectedItems.Count - 1;
for (int I = 0; I <= cds; I++)
{
MessageBox.Show("" + ListView1.SelectedItems[I].Text);
}
}
我正在尝试显示有关所选商品的信息.
这是我遇到的错误.
名称"ListView1"在当前上下文中不存在".
I am trying to display info about selected item.
This is the error I am getting.
"The name ''ListView1'' does not exist in the current context"
推荐答案
您必须记住C#区分大小写.
如果ListBox的名称是由Visual Studio编辑器分配的,则几乎可以肯定listBox1
带有小写的"l".
试试:
You have to remember that C# is case sensitive.
If the name of the ListBox was assigned by the Visual Studio Editor, then it is almost certainlylistBox1
with a lower case ''l''.
try:
int cds = listView1.SelectedItems.Count - 1;
这篇关于名称"ListView1"在当前上下文中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文