Protected Void Datagrid1_mousedown ( Object Sender, mouseeventargs E) {
// Use the hittest method to get a hittestinfo object.
System. Windows. Forms. DataGrid. hittestinfo Hi;
DataGrid Grid = (DataGrid) sender;
Hi = Grid. hittest (E. X, E. y );
// Test if the clicked area was a cell.
If (Hi. Type = DataGrid. hittesttype. Cell) {
// If it's a cell, get the gridtable and currencymanager of
// Clicked table.
Datagridtablestyle dgt = Datagrid1.tablestyles [ 0 ];
Currencymanager mycurrencymanager =
(Currencymanager) This . Bindingcontext
[Mydataset. Tables [datagrid1.datamember];
// Get the rectangle of the clicked cell.
Rectangle cellrect;
Cellrect = Grid. getcellbounds (Hi. Row, hi. Column );
// Get the clicked maid.
Datagridtextboxcolumn gridcol =
(Datagridtextboxcolumn) dgt. gridcolumnstyles [Hi. Column];
// Insert code to edit the value.
}
}
Think of MS as an inexplicable thing. It is necessary to make such complicated things.