改为: if Button = mbRight then begin if TreeView1.GetNodeAt(X, Y)<>Nil then begin TreeView1.GetNodeAt(X, Y).Selected := true; PopupMenu1.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); end; end;