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

Reader's Choice Award Winners

What are the best instant messengers, apps, editors and more? You told us, for our 2010 technology awards program. More >

iPad Central

Is Apple's new tablet computer impractical, a must-have -- or both? We'll help you figure it out. 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

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

All rights reserved.