1

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
4

1 に答える 1

1

System::Windows::Forms::Keys は列挙型であるため、(参照型ではなく) 値型です。したがって、基本クラス メソッドのシグネチャに一致させるには、ハット (^) を削除します。一般に、本当にボクシング動作が必要な場合を除いて、値型で帽子を使用するべきではありません。

http://msdn.microsoft.com/en-us/library/system.windows.forms.keys.aspx

于 2012-04-12T12:03:57.060 に答える