I have created a Datagridview class for processdialogkey(). But Iam getting following errors…Any body can help me please…
This code:
//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);
}
}
Leads to the following error:
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 is an enum, and thus a value type (not a reference type). So, to match the signature of the base class method you want to remove the hat (^). In general you shouldn’t be using the hat with a value type except where you truly do want boxing behavior.
http://msdn.microsoft.com/en-us/library/system.windows.forms.keys.aspx