开发者

.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.

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".

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 )
    开发者_C百科{
      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.

thanks in advance


Problem solved. I had to set the whole datagridview as "Read Only" (I'm familiar with 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).

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?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜