バージョン

BeforePaste イベント

ノードがクリップボードから貼り付けられる前に発生します。
シンタックス
'宣言
 
Public Event BeforePaste As BeforePasteEventHandler
public event BeforePasteEventHandler BeforePaste
イベント データ

イベント ハンドラが、このイベントに関連するデータを含む、BeforePasteEventArgs 型の引数を受け取りました。次の BeforePasteEventArgs プロパティには、このイベントの固有の情報が記載されます。

プロパティ解説
Cancel System.ComponentModel.CancelEventArgsから継承されます。 
Index 貼り付けられたツールが挿入されるインデックス。
Nodes Infragistics.Win.UltraWinTree.CancelableNodesEventArgsから継承されます。操作されるノードのコレクション。(読み取り専用)
ParentNode 貼り付けられるノードの新しい親。
使用例
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinTree

Private Sub ultraTree1_BeforePaste(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.BeforePasteEventArgs) Handles ultraTree1.BeforePaste

    Dim sb As New System.Text.StringBuilder()
    Dim node As UltraTreeNode
    Dim dr As DialogResult

    ' Setting the Tag of the Nodes collection passed into the BeforeCut
    ' and BeforeCopy events to some serializable value can be used to
    ' identify the tree that copied the nodes to the clipboard. This Tag
    ' value will be de-serialized and set on the Nodes collection that is
    ' passed into the BeforePaste event. This can be used for preventing 
    ' paste operations between trees.

    ' If these nodes weren't copied from this tree then cancel the paste
    If e.Nodes.Tag <> Me.ultraTree1.GetHashCode() Then
        e.Cancel = True
        Exit Sub
    End If

    ' Note: The BeforePaste event will be raised even if there are no
    ' nodes on the clipboard. This is done to allow other clipboard formats
    ' to be checked.

    ' The ParentNode property can be changed to specify where the
    ' pasted nodes will go. A value of Nothing will make them root nodes.
    e.ParentNode = Nothing

    ' Setting the index property will cause the nodes to be pasted
    ' in the parent's Nodes collection at that index. In this case
    ' setting the index to 0 will paste the nodes before any other
    ' nodes in the collection.
    e.Index = 0

End Sub
using System.Diagnostics;
using Infragistics.Win;
using Infragistics.Win.UltraWinTree;


private void ultraTree1_BeforePaste(object sender, Infragistics.Win.UltraWinTree.BeforePasteEventArgs e)
{
	// Setting the Tag of the Nodes collection passed into the BeforeCut
	// and BeforeCopy events to some serializable value can be used to
	// identify the tree that copied the nodes to the clipboard. This Tag
	// value will be de-serialized and set on the Nodes collection that is
	// passed into the BeforePaste event. This can be used for preventing 
	// paste operations between trees.

	// If these nodes weren't copied from this tree then cancel the paste
	if ( (int)e.Nodes.Tag != this.ultraTree1.GetHashCode() )
	{
		e.Cancel = true;
		return;
	}
		
	// Note: The BeforePaste event will be raised even if there are no
	// nodes on the clipboard. This is done to allow other clipboard formats
	// to be checked.

	// The ParentNode property can be changed to specify where the
	// pasted nodes will go. A value of null will make them root nodes.
	e.ParentNode = null;

	// Setting the index property will cause the nodes to be pasted
	// in the parent's Nodes collection at that index. In this case
	// setting the index to 0 will paste the nodes before any other
	// nodes in the collection.
	e.Index = 0;
}
参照