How to use the mouse to get the value of the cell in DBGRID

zhaozj2021-02-16  52

As shown in the 3 graph, the options in the right mumpons are different depending on the cell data pointed to by the mouse. How to achieve? The key to the problem is how to get the value of the cell pointing to the megadownload. Check BCB help, see the DBGRID: Tcustomgrid :: Mousecoord TcuStomgrid See Also ---------------------- Returns the row and column indexes of the row and color . cell that contains a point specified in screen coordinates struct TGridCoord {int X; int Y;}; TGridCoord __fastcall MouseCoord (int X, int Y); Description Call MouseCoord to locate the column and row of the cell which contains a given screen coordinate The last sentence is roughly, the last sentence can be obtained by calling the DBGRID MouseCoord method to obtain the lines and columns of the cell, but must know the coordinates of the cell in the screen. Typically, the Mousecoord event is used to get the rows and columns of the cell pointing. As long as you know the lines of cells and columns, you can get the name of the fields belonging through the cells belongs through dbgrid-> columns-> items [], and you can use the field name to determine the value in the cell: query-> fieldbyname FieldName) -> asstring. How to get the coordinate of the cell in the screen? The mouse coordinate pointing to the cell is the coordinates of the needs. How to get the coordinates of the mouse? With the MouseMove event in DBGRID, it will pass the coordinates of the mouse.

转载请注明原文地址:https://www.9cbs.com/read-18232.html

New Post(0)