D
dawuboy
Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个控件,在主窗体调用MoveTo时控件代码中的OnChange事件触发了两次,而主窗体
中没有触发。问题代码如下:
--------------------------------------------------------------------------------
请问是哪里出了问题?
中没有触发。问题代码如下:
代码:
//控件代码
unit MyTestTreeView;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ComCtrls, CSIntf;
type
TMyTestTreeView = class(TTreeView)
protected
procedure Change(Node: TTreeNode); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
{ TMyTestTreeView }
procedure TMyTestTreeView.Change(Node: TTreeNode);
begin
inherited;
CodeSite.SendMsg('控件代码中Change事件触发');
end;
constructor TMyTestTreeView.Create(AOwner: TComponent);
begin
inherited;
//
end;
destructor TMyTestTreeView.Destroy;
begin
//
inherited;
end;
end.
--------------------------------------------------------------------------------
代码:
//主窗体代码
procedure TForm1.btn2Click(Sender: TObject);
var
Node: TTreeNode;
begin
with MyTestTreeView1 do
begin
Node := Selected.getPrevSibling;
if Node <> nil then
begin
Selected.MoveTo(Node, naInsert);
end;
end;
end;
procedure TForm1.MyTestTreeView1Change(Sender: TObject; Node: TTreeNode);
begin
CodeSite.SendMsg('主窗体中Change事件触发');
end;
请问是哪里出了问题?