开发者

Getting error C3352: 'Add' : the specified function does not match the delegate type 'void (System::Object ^)'

I'm trying to implement a data grid view control and I get the this error: error C3352: 'Add' : the specified function does not match the delegate type 'int (System::Object ^)'

when I try to do this:

delegate int Add开发者_运维问答DelegateTest(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);
     }

I'm not really sure whats causing this error.

Any help would be greatly appreciated

Ok, so I changed my delegate declaration to: delegate int AddDelegateTest(cli::array^); The error goes away but I get a runtime exception now:

An unhandled exception of type 'System.Reflection.TargetParameterCountException' occurred in mscorlib.dll Additional information: Parameter count mismatch.

Does anyone know why this happens?

thanks


    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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜