我是在添加了下面的代码后,然后再返回界面去出现这种情况的,谢谢
void InitializeComponent(void)
{
this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(2) {this->Column1,
this->Column2});
this->dataGridView1->Location = System::Drawing::Point(13, 163);
this->dataGridView1->Name = L"dataGridView1";
this->dataGridView1->RowTemplate->Height = 23;
this->dataGridView1->Size = System::Drawing::Size(296, 150);
this->dataGridView1->TabIndex = 5;
//上面是自带的,加上下面的就出错了,但是运行还是可以的,指再没法编辑了,谢谢
this->dataGridView1->Rows[0]->Cells[0]->Value = "1";
this->dataGridView1->Rows[0]->Cells[1]->Value = "2";
this->dataGridView1->Rows[0]->Cells[2]->Value = "3";
}
------解决方案--------------------
貌似一共只有两列吧?Cell[2]越界?
------解决方案--------------------
这是用非托管代码写的吗,不懂,绑定吧