visual-c++ - Visual C++ boolean 错误

标签 visual-c++ compiler-errors boolean

我已经为Visual C++中的复选框编写了这段代码。它包含一个 bool(boolean) 值,如下所示:

    bool LeftRightButton;
#pragma endregion
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
         }
private: System::Void checkBox1_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
             if (checkbox1->Checked) {
                LeftRightButton = True;
             } else {
                LeftRightButton = False;
             }

但是当我调试程序时,它显示错误消息:
error C2065: 'checkbox1' : undeclared identifier
error C2227: left of '->Checked' must point to class/struct/union/generic type
error C2065: 'True' : undeclared identifier
error C2065: 'False' : undeclared identifier

我不知道我的代码有什么问题,因为我没有任何类。

最佳答案

您的checkBox1_CheckedChanged函数是通过代码生成自动创建的,还是您自己编写的?在我看来,您没有声明为checkBox1 ..的对象,或者至少没有一个不在范围内的对象。

更新-使用发件人(语法可能不正确):

if ((Checkbox)sender -> Checked) ...

关于visual-c++ - Visual C++ boolean 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25187855/

相关文章:

c++ - 内联函数和调用约定

c - 使用 scanf_s 读取一个字符

python - 编译Cython代码时出现"error: Unable to find vcvarsall.bat"

compiler-errors - CodevisionAVR类型定义

c++ - MSVC 2008 16 字节结构成员对齐异常

c++ - C++严格混叠规则使用Qt和QLinkedList编译错误

java - 我如何在if语句中包含多个条件?

javascript - 为什么 (null == false) 和 (null == true) 都返回 false?

jsf - 绑定(bind)h :selectBooleanCheckbox value to int/Integer instead of boolean/Boolean

c# - 如何从大量可为空的 boolean 值中返回一个 boolean 值?