【问题标题】:'SelectedIndex' : Undeclared identifier in C++'SelectedIndex':C++ 中未声明的标识符
【发布时间】:2016-10-15 19:02:28
【问题描述】:

我正在编写一个引用状态的简单程序 SelectedIndex 在任何给定点都可以是数字 0 - 9

SelectedIndex 由下拉列表控制。

当我尝试引用 SelectedIndex 的状态时:

if (SelectedIndex == 0)
{
textBox1->Text = "C Egyptian";
}

编译时出现“未声明的标识符”错误。

我只想能够为我的条件引用状态 SelectedIndex。

有什么想法吗?

【问题讨论】:

  • 只是不在您使用它的特定范围内
  • dropdownlist->SelectedIndex?这里只是猜测。 minimal reproducible example 请。
  • private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { if (sender == comboBox1) { String^ ps = String::Concat(L"新索引为 ", (Object^)(comboBox1->SelectedIndex).ToString()); MessageBox::Show(ps, L"索引变化"); } }
  • @Cyber​​neticJesus 请在您的问题中添加此类附加信息。

标签: c++ undeclared-identifier


【解决方案1】:

Nvm 很抱歉提出了 n00b 问题...我对 C++ 很陌生,但实际上我自己在 VS 中自己猜测了一下。

问题是我应该一直在使用

if (comboBox1->SelectedIndex == 0)
{
textBox1->Text = "C Egyptian";
}

而不是

if (SelectedIndex == 0)
{
textBox1->Text = "C Egyptian";
}

祝你好运

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多