Solved

TDBGrid

Posted on 1998-02-02
1
403 Views
Last Modified: 2010-05-18
hi
i"m using the TdbGrid ...
is there is any way to know the cell cordinat that i"m standgin on ... because i want to put on this cell cordinat my own Tcontrol (to enter data), and  how i know when the user make scroll action (so i'll know the new cell cordinate)

10x
asi
0
Comment
Question by:asi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1358130
Hi asi,

to know the cell coördinats :

do you just want to select the cell? Here is an example :
                   (Look at the header of the form. Think the way of getting the row and col selected is
                   interesting) If I'm wrong, please specify the problem.

                   try it this way:

                   unit unit1;

                   interface

                   uses
                     SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
                     Forms, Dialogs, DB, DBTables, Grids, DBGrids;

                   type
                     TForm1 = class(TForm)
                       DBGrid1: TDBGrid;
                       DataSource1: TDataSource;
                       Table1: TTable;
                       procedure DBGrid1ColEnter(Sender: TObject);
                       procedure DataSource1DataChange(Sender: TObject; Field: TField);
                       procedure DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
                       Field: TField; State: TGridDrawState);
                     private
                       { Private declarations }

                     public
                       { Public declarations }
                       procedure ShowRowCol;
                     end;
                     THack = class(TDBGrid);

                   var
                     Form1: TForm1;

                   implementation

                   {$R *.DFM}

                   procedure TForm1.ShowRowCol;
                   begin
                     caption := 'Row: ' + IntToStr(THack(DBGrid1).row) + ' ' + 'Col: ' +
                   IntToStr(THack(DBGrid1).col);
                   end;

                   procedure TForm1.DBGrid1ColEnter(Sender: TObject);
                   begin
                     ShowRowCol;
                   end;

                   procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
                   begin
                     if (Sender as TDataSource).State = dsBrowse then ShowRowCol;

                   end;
                   Procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
                     Field: TField; State: TGridDrawState);
                   begin
                      If gdFocused in State then
                       with (Sender as TDBGrid).Canvas do begin
                       Brush.Color := clRed;
                       FillRect(Rect);
                       TextOut(Rect.Left, Rect.Top, Field.AsString);
                       end;
                   end;

                   end.

When a user moves the scrollbar, it doesn't says that the active cell changes : so you need to find the movement event another way. Like pushing the enter or tab, or arrow keys.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month4 days, 6 hours left to enroll

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question