DataGridView Class - Errors()
DataGridView Class - Errors()
我为 processdialogkey() 创建了一个 Datagridview 类。但是我遇到了以下错误...任何身体都可以帮助我...
此代码:
//Header File MyDGV.h
public ref class MyDGV : public DataGridView
{
protected:
virtual bool ProcessDialogKey(System::Windows::Forms::Keys^ keyData) override;
};
//MyDGV.CPP File
#include "StdAfx.h"
#include "MyDGV.h"
bool MyDGV::ProcessDialogKey(System::Windows::Forms::Keys^ keyData)
{
Keys^ key = keyData & (System::Windows::Forms::Keys::KeyCode);
if (key == System::Windows::Forms::Keys::Enter)
{
DataGridView::OnKeyDown(gcnew KeyEventArgs(System::Windows::Forms::Keys^ keyData));
return true;
}
else
{
return DataGridView::ProcessDialogKey(System::Windows::Forms::Keys^ keyData);
}
}
导致以下错误:
Errors:
01. warning C4490: 'override' : incorrect use of override specifier; 'MyDGV::ProcessDialogKey' does not match a base ref class method
02.error C3063: operator '&': all operands must have the same enumeration type
03.error C2275: 'System::Windows::Forms::Keys' : illegal use of this type as an expression
04.error C2275: 'System::Windows::Forms::Keys' : illegal use of this type as an expression
System::Windows::Forms::Keys是一个枚举,因此是一个值类型(不是引用类型)。 因此,为了匹配基类方法的签名,您需要删除帽子 (^)。 一般来说,你不应该使用带有值类型的帽子,除非你确实想要拳击行为。
http://msdn.microsoft.com/en-us/library/system.windows.forms.keys.aspx
相关文章:
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- 使用模板进行堆栈实现; "name followed by :: must be a class or namespace"
- "Undefined class"作为is_base_of的论据
- 如何将class.cpp和class.hpp编译为一个.o文件
- '{'标记之前的预期类名,然后在预声明时无效使用不完整的类型'class class_name'
- 如何使用"derived input class"创建派生类?
- 错误:"Left of getValue must have class/struct/union"
- ' class a : b ' 和 ' class a : public b ' 之间的继承类不同
- Pybind11 Class Definition
- 在C++中使用没有合作伙伴Class/Cpp文件的头文件是否实用
- C2011 'CMemDC':Visual Studio 2019中的'class'类型重新定义
- TypeError: [c++ addon class] 不是构造函数
- C++ class template
- 当初始值设定项是基类名时'initializer does not name a non-static data member or base class'错误
- Clearing Class Foo with new(pFoo) Foo()
- C++ class vs a library
- C++ Class Errors
- DataGridView Class - Errors()