Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 28 Mar 2024, 23:32

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 12 Mar 2013, 10:52 
Offline

Joined: 21 May 2012, 12:29
Posts: 9
Hi,
I want to capture text from specific cell (Ex: cell in row number 3 and column number 4) . How can I do it? Or how to get text from cell when mouse move?


Top
 Profile  
 
PostPosted: 13 Mar 2013, 09:45 
Offline
Администратор

Joined: 22 Dec 2011, 20:19
Posts: 335
Hello

Demo project is attached.

And here is the main part of the code.
When user moves a mouse over the grid, it writes text of a cell under the mouse poiter to a TLabel: Label1.

Code:
// Not all required methods are public
// So use trick to get to protected methods
type
  TDBGridEhCrack = class (TDBGridEh);

procedure TForm1.DBGridEh1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  Cell: TGridCoord;
  Column: TColumnEh;
begin
  Cell := DBGridEh1.MouseCoord(X, Y);
  if (Cell.X >= 0) and (Cell.Y >= 0) then
  begin
    if Cell.X < DBGridEh1.IndicatorOffset then
      Label1.Caption := 'Indicator'
    else if Cell.Y < DBGridEh1.TopDataOffset then
      Label1.Caption := 'Title'
    else begin
      TDBGridEhCrack(DBGridEh1).InstantReadRecordEnter(Cell.Y - DBGridEh1.TopDataOffset);
      try
        Column := DBGridEh1.Columns[TDBGridEhCrack(DBGridEh1).RawToDataColumn(Cell.X)];
        Label1.Caption := Column.DisplayText;
      finally
        TDBGridEhCrack(DBGridEh1).InstantReadRecordLeave;
      end;
    end;
  end else
    Label1.Caption := '';
end;


Best regards
Admin

_________________
Best regards
Admin


Top
 Profile  
 
PostPosted: 17 Mar 2013, 09:50 
Offline

Joined: 21 May 2012, 12:29
Posts: 9
Good idea!!
Thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group