Gridview in C++ windows form app cant edit
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:
- EditOnEnter
- 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.
精彩评论