我創建了一個未綁定的DatagridView,這些行在運行期間手動輸入,並且應該是可編輯的。.net無法在運行時編輯Datagridview中的值
使用命令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");
}
}
}
我的應用程序是用C++語言編寫的Windows窗體。
在此先感謝
我敢肯定,Rows-> Add()方法將創建一個新的行與所提供的列數據。 http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rows.aspx – 2011-01-28 19:43:04