I have a data grid displaying results from a sql database. What I want to do is make it so that when I double click on a cell in the datagrid, a new window appears where that cell can be edited. I also would like to have all the info for that cell to be autogenerated into editable fields when the cell is double clicked. Any help or 开发者_JAVA百科links to tutorials is appreciated. Thanks.
Try this DataGridView.CellDoubleClick Event
Did you consider using data binding? Simply put, you can bind your items list to DataGrid
, and current item (eg. selected/double clicked) to your edit form's controls (TextBox
, Label
and whatever else you might have there).
Here are good starting points for windows forms: #1, #2. They cover problem you're facing. You can find data binding tutorials for ASP/WPF easily too, but especially first link covers entire concept pretty well.
精彩评论