0
我是新來的C + +和Im使用VS2010。 有人可以檢查下面的代碼並幫助解決它嗎?每次調用功能UpdateDataGrid(unsigned char CANPacket[15])
被調用時,以下消息將顯示在新窗口中並且應用程序關閉。VS C++問題與InvokeRequired /委託無效
An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll
Additional information: Object of type 'System.Byte' cannot be converted to type 'System.Byte*'.
我不得不使用unsinged char
數據類型,在這個項目中沒有String^
。 有什麼方法可以糾正我的代碼嗎?
//Piece of my code
namespace VCCDC {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Threading;
public ref class Form1 : public System::Windows::Forms::Form
{
delegate void UpdateDataGridCallback(unsigned char CanPacket[15]);
private: void UpdateDataGrid(unsigned char CANPacket[15]) {
if (this->dataGridView1->InvokeRequired) {
UpdateDataGridCallback^ d = gcnew UpdateDataGridCallback(this,&VCCDC::Form1::UpdateDataGrid);
this->Invoke(d,gcnew unsigned char(CANPacket[15]));
}
else {
//Update dataGridView1 with new data
}
}
}
}]