Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Getting DBGrid cell value from moused-over cell


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: May 25, 2014 10:57 AM Last Post By: Kevin Morris
Kevin Morris

Posts: 52
Registered: 1/8/13
Getting DBGrid cell value from moused-over cell  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 21, 2014 10:23 AM
Platform: DXE3
Control: TDBGrid

Goal: My grid has 4 columns and about a hundred rows. I want to make only certain cells clickable. I have all the fonts/underlines etc working so that the grid appears to have mostly non-clickable cells (no underline, black text), and only a few clickable cells, (hotlight colored font, with underline). I want the cursor to be crHandPoint ONLY on the clickable cells, and crDefault (arrow) on the non-clickable cells. I say "cells" and not "rows" or "columns" because not every cell in a particular column will be clickable, and not every cell in a particular row will be clickable.

All the examples I can find on the Internet talk about the Selected row and getting the field value from the underlying data source/set. My users will be mousing over all rows, and so if I use the Selected row as my source of data, the mouse cursor will change only according to what ever row they happened to have selected, when they start moving the mouse around. (which will be wrong 99% of the time)

I figured that I could use the TClientDataSet's Lookup() function to return a non-selected row's field value, IF I could get the unique identifier for a given row ("obj_guid") from a hidden column in the grid. But that's as far as I got.

Here is my code, with the one single line indicated where I need the cell value under the mouse.

procedure TfrmMyProject.dbgClnEvtLogMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
var lCoord: TGridCoord;  is_clk_cel: Boolean;  obj_guid, tbl_nm: String;  cds: TClientDataSet;  v: Variant;
begin
  lCoord := dbgClnEvtLog.MouseCoord(X,Y);
  if (lCoord.X = -1) or (lCoord.Y = -1) then
    begin
      if not (dbgClnEvtLog.Cursor = crDefault) then
        dbgClnEvtLog.Cursor := crDefault;
      Exit;
    end;
 
    is_clk_cel := (Pos(';' + dbgClnEvtLog.Columns[lCoord.X].FieldName + ';', ';Event_Name;') > 0);
    if is_clk_cel then
      begin
        obj_guid := dbgClnEvtLog....  <<<------- WHAT GOES HERE?
        v := dmCln.cdsEvtLog.Lookup( 'OBJ_GUID', VarArrayOf([obj_guid]), 'Table_Name');
        is_clk_cel := is_clk_cel and (Pos(';' + VarToStr(v) + ';', ';JET_APT;JET_SVR;') > 0);}
      end;
 
  if is_clk_cel then
    begin
      if not (dbgClnEvtLog.Cursor = crHandPoint) then
         dbgClnEvtLog.Cursor := crHandPoint
    end
  else
    begin
      if not (dbgClnEvtLog.Cursor = crDefault) then
        dbgClnEvtLog.Cursor := crDefault;
    end;
end;
 


Thanks in advance for any help you can provide.
Kevin Morris

Posts: 52
Registered: 1/8/13
Re: Getting DBGrid cell value from moused-over cell  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 25, 2014 10:57 AM   in response to: Kevin Morris in response to: Kevin Morris
No solution. I just wanted to get this off my "Unanswered" list.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02