1. Home
  2. Computing & Technology
  3. Delphi Programming

How to get DBGrid Cell coordinates

By Zarko Gajic, About.com

The code to show over what cell in a DBGrid the cursor is, and how to change the cursor over the tite bar:

~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TForm1.GridMouseMove
  (Sender: TObject; Shift: TShiftState; X, Y: Integer) ;
var
   pt: TGridcoord;
begin
  pt:= Grid.MouseCoord( x, y ) ;

  //change the cursor whe over title
  if pt.y=0 then
    Grid.Cursor:=crHandPoint
  else
    Grid.Cursor:=crDefault;

   If pt.X > 0 Then
     Caption := Format( 'col: %d, row: %d, title: %s',
                [pt.x, pt.y, Grid.columns[pt.x-1].title.caption] )
   Else
     Caption := Format( 'col: %d, row: %d',[pt.x, pt.y] ) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Retrieving a list of installed Applications on Windows
« How to split a string into an array

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2002 Delphi Tips
  7. How to get DBGrid Cell coordinates

©2009 About.com, a part of The New York Times Company.

All rights reserved.