简体   繁体   English

.net在运行时无法在Datagridview中编辑值

[英].net Can't edit values in Datagridview on Runtime

I created an unbound DatagridView which rows are input manually during runtime and are supposed to be editable. 我创建了一个未绑定的DatagridView,该行在运行时是手动输入的,应该可以编辑。

Using the command DataGridView->Rows->Add(string,..) it creates the row properly but it doesn't allow me to edit the values manually, even though it's not on "Read Only". 使用命令DataGridView-> Rows-> Add(string ..),它可以正确创建行,但是即使我不在“只读”上,也不允许我手动编辑值。

The code used for input:


    private: System::Void ButtomSave_Click(System::Object^  sender, System::EventArgs^  e) {     

  String^ folderName;
/*DataGridViewComboBoxColumn^ cmbCol = gcnew DataGridViewComboBoxColumn;
cmbCol->HeaderText = "Sagital/Coronal";
cmbCol->Items->Add("-");
cmbCol->Items->Add("Sagital");
cmbCol->Items->Add("Coronal");
dataGridView1->Columns->Add(cmbCol);*/
  FolderBrowserDialog^ folderBrowserDialog1 = gcnew FolderBrowserDialog;
  folderBrowserDialog1->Description="Select the folder containing the image sequences folder";
  // Do not allow the user to create new files via the FolderBrowserDialog.
  folderBrowserDialog1->ShowNewFolderButton = false;  
    // Default to the My Documents folder.
  folderBrowserDialog1->RootFolder = Environment::SpecialFolder::Personal;
  if ( folderBrowserDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
    {
      folderName = folderBrowserDialog1->SelectedPath;
      array<String^>^subdirectoryEntries = Directory::GetDirectories( folderName );
   DataGridViewRow row;
      System::Collections::IEnumerator^ myEnum = subdirectoryEntries->GetEnumerator();
      while ( myEnum->MoveNext()){

        dataGridView1->Rows->Add(myEnum->Current,"Sagital");  

      }
    }
}

My application is written using Windows Forms in C++ language. 我的应用程序是使用Windows窗体以C ++语言编写的。

thanks in advance 提前致谢

Problem solved. 问题解决了。 I had to set the whole datagridview as "Read Only" (I'm familiar with Qt). 我必须将整个datagridview设置为“只读”(我对Qt很熟悉)。

To clarify my own question, to make the datagridview cells editable right click on it, then properties->behaviour section->ReadOnly->False (it's True by default). 为了阐明我自己的问题,使datagridview单元可编辑,右键单击它,然后单击properties-> behaviour部分-> ReadOnly-> False(默认情况下为True)。

Thanks for the replies 感谢您的答复

Can you actually add a string to the row? 您可以实际在行中添加字符串吗? Wouldn't you have to create a Row object to add to the collection? 您是否不必创建Row对象以添加到集合中?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM