标签:des style blog http color strong io for
TreeView节点拖拉操作1
//事先设置 TreeView1.DragMode= dmAutomatic;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;
type
TForm1 = class(TForm)
TreeView1: TTreeView;
procedure TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
procedure TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//var
// node:TTreeNode;
procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
// node := TreeView1.GetNodeAt(X, Y);
// Caption:=node.Text;
Accept := Source = Sender;
if not Accept then exit;
end;
procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
with TreeView1 do
begin
if (Sender <> Source) then exit;
if (DropTarget = nil) then exit;
if (DropTarget = Selected) then exit;
Selected.MoveTo(DropTarget,naAddChildFirst);
end;
end;
end.
TNodeState = (nsCut, nsDropHilited, nsFocused, nsSelected, nsExpanded);
TNodeAttachMode = (naAdd, naAddFirst, naAddChild, naAddChildFirst, naInsert);
TAddMode = (taAddFirst, taAdd, taInsert);
拖拽时可以看见拖拽的图标如果有的话
TreeView节点拖拉操作1,布布扣,bubuko.com
TreeView节点拖拉操作1
标签:des style blog http color strong io for
原文地址:http://www.cnblogs.com/xe2011/p/3876311.html