Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There must be missing an easy way to double-click on a DataGridViewCell and be able to get it in edit mode so you can type into the cell and change the value.
here is my project code if you need the full source (Form1.cs, line 4533) and the DataGridView is on the "Settings" tab .
I have read some things but I would like to avoid as many event handlers as possible.
https://dl.dropboxusercontent.com/u/60712778/MCMyVault.zip[^]

C#
DataGridViewCell cell = dataGridViewSettings.Rows[e.RowIndex].Cells[e.ColumnIndex + 1];
cell.InitializeEditingControl(e.RowIndex, dataGridViewSettings.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value, dataGridViewSettings.Rows[e.RowIndex].DefaultCellStyle);

//   dataGridViewSettings.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].InitializeEditingControl(e.RowIndex, dataGridViewSettings.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value, dataGridViewSettings.Rows[e.RowIndex].DefaultCellStyle);
//   dataGridViewSettings.EditMode = DataGridViewEditMode.EditOnEnter;

dataGridViewSettings.EditMode = DataGridViewEditMode.EditOnEnter;
dataGridViewSettings.ReadOnly = false;
Posted
Comments
Richard MacCutchan 20-Mar-14 11:33am    
Why do you want to avoid event handlers, since that is one of the essentials of the .NET framework?
JoeSox 20-Mar-14 11:37am    
It just seems intuitive that I am missing something that doesn't require event handlers to pull it off, seems like something should be built in to the control to make it happen. If not, I will use handlers.
Richard MacCutchan 20-Mar-14 11:56am    
The proper use of event handlers is the preferred way to do it. You do not have to add them at design time, since they are just like public properties that can be set and reset at any point in your application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900