1. Такие вопросы всех пугают... Потому что на них есть ответы в хелпе...
function MouseCoord(X, Y: Integer): TGridCoord;
Returns the row and column indexes of the cell that contains a point specified in screen coordinates.
type TGridCoord = record
X: Longint;
Y: Longint;
end;
function MouseCoord(X, Y: Integer): TGridCoord; |
|
Description
Call MouseCoord to locate the column and row of the cell which contains a given screen coordinate. Usually, MouseCoord is used to locate the cell that is under the mouse.
2. Установить текущую колонку можно легко:
DBGrid.SelectedIndex:=MouseCoord(MouseX,MouseY).Y; |
|
а вот строчку - нельзя... То есть прямо из DBGrid нельзя - надо в DBGrid.DataSource.DataSet использовать Locate, MoveBy иил что-то ещё подобное...
А вообще при клике мышкой DBGrid сам всё это делает, если хочется переопределить чего-нибудь, так надо заглянуть в исходники VCL и посмотреть...
Не бейте, если я не прав...