I would like to have a right-click on the TFlexCelGrid select the corresponding cell and pop up a menu. However, I am not finding a MouseToCell method like that of TCustomDrawGrid. (Using v3 of FlexCel)
Is there a corresponding method?
Hi,
FlexCelGrid descends from TCustomGrid, not from TCustomDrawGrid, so some methods might be missing. But, in this particular case it is simple. MouseToCell is:
procedure TCustomDrawGrid.MouseToCell(X, Y: Integer; var ACol, ARow: Longint);
var
Coord: TGridCoord;
begin
Coord := MouseCoord(X, Y);
ACol := Coord.X;
ARow := Coord.Y;
end;
And MouseCoord is available in FlexCelGrid. So you could just call MouseCoord directly.
Ok -- will give that a try. Thanks!
Please excuse my ignorance, but I do not write VCLs. How would I get the above MouseToCell procedure to be an event of TFlexCelGrid?
Richard,
I am not sure I am following. MouseToCell isn't an event in TDrawGrid either, it is just a method that you can implement as above. You have OnMouseDown, OnClick, OnMouseMove, etc events, which happen when you click, move the mouse etc. But MouseToCell isn't an even't (when would it fire?). It is just a method that you can call to convert x,y coordinates to a cell.
What is what you want to do? To show a popup menu you would assign the property "PopupMenu" of the FlexCelGrid (or the drawGrid). If you want to do customizations, you have events like "OnPopup" in the TPopupMenu component that you assign to the grid. If you want even more flexibility, you can handle the event OnMouseUp and do everything manually.
Sorry -- I had a senior moment. :(
I thought I had to use Mouse.CursorPos to get a TPoint because I forgot about TFlexCelGrid.OnMouseDown. I got it working just fine. Sorry about that.