1. Computing

How to get DBGrid Cell coordinates

From , former 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

About Delphi Programming Tips - 2002
Top Related Searches delphi tips dbgrid whe cursor delphi caption

©2013 About.com. All rights reserved.