Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve datagrid value on mouse click

Status
Not open for further replies.

AP81

Programmer
Apr 11, 2003
740
AU
I am trying to retrieve the value of the data in a cell when the mouse is clicked (or preferably double-clicked) or a key is pressed. The key press if fine, however I can't seem to get the double-click to work. Any pointers in the right direction?

Here is my code for the KeyPress:


procedure TfrmMain.dbgSearchResultsKeyPress(Sender: TObject;
var Key: Char);

var
strText : string;
begin
strText := dbgSearchResults.SelectedField.Value;
sbMsg.SimpleText := strText;
end;

end.




------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
This is fairly straightforward. Create an handler for the OnCellClick event in your DBGrid:

Code:
procedure TForm1.dbgSearchResultsCellClick(Column: TColumn);
begin
  sbMsg.SimpleText := Column.Field.AsString;
end;

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top