2010-10-17 140 views
0

我不知道如果我失去了一些東西,但對於我的生活我不能讓網格是可編輯的。Gridview在C++窗體窗體應用程序不能編輯

我正在做的是將文件加載到字典中,然後將該字典綁定到網格。

網格顯示詞典中的數據,但我不能編輯網格中的任何數據。

我試圖改變模式也:

  1. EditOnEnter
  2. EditOnKeyStroke

而縹緲。

任何想法? PS:我在C++中沒有做太多的GUI工作,所以也許我忽略了一些東西。

這是我如何加載網格。

Dictionary<String^, String^>^ data = gcnew Dictionary<String^, String^>(); 
BindingSource^ bindingSource1 = gcnew BindingSource(); 

// Read and display lines from the file until the end of the file is reached. 
while (line = sr->ReadLine()) 
{ 
    array<String^>^split = line->Split(chars);  
    data->Add(split[0], split[1]); 
} 


dataGridView1->DataSource = bindingSource1; 
bindingSource1->DataSource = data; 

dataGridView1->AutoResizeColumns(DataGridViewAutoSizeColumnsMode::AllCells); 

提前致謝。

回答

0

我發現了這個問題。您必須使用可更新的來源,並且字典不可更新。

一旦我更改爲DataTablew,問題就解決了。

相關問題