TreeView.BeforeSelect イベント
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ツリー ノードが選択される前に発生します。
public:
event System::Windows::Forms::TreeViewCancelEventHandler ^ BeforeSelect;
public event System.Windows.Forms.TreeViewCancelEventHandler BeforeSelect;
member this.BeforeSelect : System.Windows.Forms.TreeViewCancelEventHandler
Public Custom Event BeforeSelect As TreeViewCancelEventHandler
イベントの種類
例
次のコード例は、このメンバーの使用方法を示しています。 この例では、イベント ハンドラーは、 BeforeSelect イベントの発生を報告します。 このレポートは、イベントがいつ発生するかを学習するのに役立ち、デバッグに役立ちます。 複数のイベントや頻繁に発生するイベントについて報告するには、 MessageBox.Show を Console.WriteLine に置き換えるか、メッセージを複数行の TextBoxに追加することを検討してください。
コード例を実行するには、TreeViewという名前の型のインスタンスを含むプロジェクトTreeView1貼り付けます。 次に、イベント ハンドラーが BeforeSelect イベントに関連付けられていることを確認します。
private void TreeView1_BeforeSelect(Object sender, TreeViewCancelEventArgs e) {
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Node", e.Node );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Action", e.Action );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "BeforeSelect Event" );
}
Private Sub TreeView1_BeforeSelect(sender as Object, e as TreeViewCancelEventArgs) _
Handles TreeView1.BeforeSelect
Dim messageBoxVB as New System.Text.StringBuilder()
messageBoxVB.AppendFormat("{0} = {1}", "Node", e.Node)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Action", e.Action)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Cancel", e.Cancel)
messageBoxVB.AppendLine()
MessageBox.Show(messageBoxVB.ToString(),"BeforeSelect Event")
End Sub
注釈
イベントの処理方法の詳細については、「イベントの 処理と発生」を参照してください。