大家好!第一次使用Visual Studio 2008 Windows Form Application with c++。
我想在表单上放一个dataGridView。没关系。但是当添加一列时,在gridView上出现2列。第一个没有标题(这是我不想要的),第二个是好的(我的专栏)。我试着从代码中设置列号,但是同样的事情发生了。
有解决这个问题的办法吗?
谢谢,安德鲁。
//
// table
//
this->table->AllowUserToAddRows = false;
this->table->AllowUserToDeleteRows = false;
this->table->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->table->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(1) {this->Column1});
this->table->Location = System::Drawing::Point(13, 89);
this->table->Name = L"table";
this->table->ReadOnly = true;
this->table->Size = System::Drawing::Size(240, 150);
this->table->TabIndex = 2;
//
// Column1
//
this->Column1->HeaderText = L"Column1";
this->Column1->Name = L"Column1";
this->Column1->ReadOnly = true;
是否在构造函数中添加列?
我过去遇到过一个问题,在构造函数中添加的项被添加了两次,因为(我认为)构造函数被调用以使控件出现在设计器视图中(然后被添加到实例中),然后在运行程序时再次出现。
如果这就是你的情况,你需要检查你是不是在设计模式。
根据上下文有几种不同的检查方法-参见如何判断。net代码是否正在由Visual Studio设计器运行