Nesler, Thomas J wrote: > I have a DBGRid and I would like to simplify the actions needed to > delete a record. I plan to have the user Right click the record and > then have the Deletion action occur on the table.
Wait -- you want the mere act of right-clicking to delete the record? That doesn't sound good. Can the deletion be undone? Users have been trained that right-clicking something will display a context menu, so when they want to do something to the grid or to the cell, they're likely to try right-clicking it. Don't surprise them by doing in irrevocable action. > My problem is getting the system to recognize a Right click inside the > cell. The system sends wm_RButtonDown and wm_RButtonUp messages to grids just like it sends them to everything else. When the grid receives a wm_RButtonUp event, it displays the popup menu for the corresponding column, if the column has a menu assigned to it. The grid also fires its OnMouseUp event whenever a mouse button is released. Parameters to the event handler include the mouse button and the control keys that were down at the time, as well as the position of the click, in client coordinates. > I tried using the MouseDown event but that is for the entire grid and > only when I click on the grid, does it work. Ideally, I would like to > detect the rightclick using the OnCellClick event, but there does not > seem to be a way to do this. Can you detect a right-click event? Can you detect the cursor position? Can you translate a coordinate into its corresponding cell? If you can do all those, then you're all set. -- Rob

