How to detect a double-click in a column of a TDBGrid (Views: 100)
When a user double-clicks on a DBGrid, how can I tell which column they were double-clicking on? Or does that double-click only apply to an entire row? I'd like to set that field to toggle values everytime the user double-clicks.
procedure TForm1.DBGrid1DblClick(Sender: TObject);
with Sender as TDBGrid do
pt := ScreenToClient(pt);
gc := MouseCoord(pt.x, pt.y);
if Columns[gc.X - 1].Color = clRed then
Columns[gc.X - 1].Color := clBlue
Columns[gc.X - 1].Color := clRed;
No need for the "hack" class technique here, though that also works.
<< Back to main page