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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using TNotifyEvent

Status
Not open for further replies.

xdracox

Programmer
May 20, 2005
16
US
Hi, I'm new to these forums and have only been using Delphi 7 for about one week.
Most of the time, I have been able to find solutions to my problems, but this time I'm stuck. I do not know how to use the TNotifyEvent, like use it as a procedure.
 
Well, I want to do something on TTreeView.OnDblClick but I have no idea how to get to that event.
 
Sorry, but that didn't tell me how to use the OnDblClick event for the TTreeView component.
 
Sorry, but i don't understand what you mean when you say "how to use OnDoubleClick event"

Giovanni Caramia
 
I mean, do something when an item in the tree view gets double clicked. Sorry for the confusion.
 
Code:
procedure TForm1.TreeView1DblClick(Sender: TObject);
var
  tNode: TTreeNode;
begin
  tNode := TreeView1.Selected ;
  if tNode = nil then
    exit
  else
    showmessage(tnode.Text);
end;

It's this what you are looking for?

Giovanni Caramia
 
Yes, I have tried that but it doesn't seem to work.
 
The code is working fine with D7, are you sure your TreeView are named TreeView1 ?
 
Why ? what's the error if any ?
On my pc it works!
Try again on a new project.
Drag on your form a TreeView component from Win32-Pallet. Click on it with rigth mouse button, and in Items Editor add some nodes (Items and SubItems)

In DoubleClick event of TreeView component copy my code from previus post and i'm sure it shall work.
Here all the unit:

Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    TreeView1: TTreeView;

    procedure TreeView1DblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.TreeView1DblClick(Sender: TObject);
var
  tNode: TTreeNode;
begin
  tNode := TreeView1.Selected ;
  if tNode = nil then
    exit
  else
    showmessage(tnode.Text);
end;

end.

Giovanni Caramia
 
It's ok, I figured it out. Thanks for all the help though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top