Visual studio 2008 获取错误C3352:“添加”:指定的函数与委托类型“void(System::Object^)”不匹配
我正在尝试实现数据网格视图控件,但遇到以下错误:错误C3352:“添加”:指定的函数与委托类型“int System::Object^”不匹配 当我尝试这样做时:Visual studio 2008 获取错误C3352:“添加”:指定的函数与委托类型“void(System::Object^)”不匹配,visual-studio-2008,visual-c++,datagridview,delegates,Visual Studio 2008,Visual C++,Datagridview,Delegates,我正在尝试实现数据网格视图控件,但遇到以下错误:错误C3352:“添加”:指定的函数与委托类型“int System::Object^”不匹配 当我尝试这样做时: delegate int AddDelegateTest(System::Object^); if(ColourGridViewControl->InvokeRequired) { array<String^>^row1 = gcnew array<String^> {"red
delegate int AddDelegateTest(System::Object^);
if(ColourGridViewControl->InvokeRequired)
{
array<String^>^row1 = gcnew array<String^> {"red","blue","yellow","green","white"};
//This gives an error
AddDelegateTest^ hTest = gcnew AddDelegateTest(ColourGridViewControl->Rows, &System::Windows::Forms::DataGridViewRowCollection::Add);
this->BeginInvoke(hTest,row1);
}
我不确定是什么导致了这个错误
任何帮助都将不胜感激
好的,我将我的委托声明更改为:
delegate int AddDelegateTestcli::array^;
错误消失了,但我现在得到一个运行时异常:
mscorlib.dll中发生类型为“System.Reflection.TargetParameterCountException”的未处理异常。其他信息:参数计数不匹配
有人知道为什么会这样吗
谢谢
delegate int AddDelegateTest(array<Object^>^);
...
array<String^>^ row1 = gcnew array<String^> {"red","blue","yellow","green","white"};
AddDelegateTest^ hTest = gcnew AddDelegateTest(dataGridView1->Rows,
&System::Windows::Forms::DataGridViewRowCollection::Add);
array<Object^>^ args = gcnew array<Object^> { row1 };
this->BeginInvoke(hTest, args);