开发者

Gridview in C++ windows form app cant edit

开发者 https://www.devze.com 2023-01-20 17:23 出处:网络
I am not sure if I am missing something, but for the life of me I cannot get the grid to be editable.

I am not sure if I am missing something, but for the life of me I cannot get the grid to be editable.

All I am doing is loading a file to a Dictionary, t开发者_Python百科hen binding that Dictionary to the grid.

The grid displays the data in the Dictionary, but I cant edit any data in the grid.

I tried changing the modes also:

  1. EditOnEnter
  2. EditOnKeyStroke

And Nada.

Any ideas? PS: I have not done much GUI work in C++, so maybe I am overlooking something.

Here is how I load the grid.

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);

Thank in advance.


I found the problem. You have to use an update-able source and a Dictionary is not update-able.

Once I changed to a DataTablew, problem solved.

0

精彩评论

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