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

How to get DBGrid Cell coordinates

By , About.com Guide

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

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. 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.