TreeNodeCollection.IsReadOnly TreeNodeCollection.IsReadOnly TreeNodeCollection.IsReadOnly TreeNodeCollection.IsReadOnly Property

定義

コレクションが読み取り専用かどうかを示す値を取得します。Gets a value indicating whether the collection is read-only.

public:
 property bool IsReadOnly { bool get(); };
public bool IsReadOnly { get; }
member this.IsReadOnly : bool
Public ReadOnly Property IsReadOnly As Boolean

プロパティ値

コレクションが読み取り専用の場合は true。それ以外の場合は falsetrue if the collection is read-only; otherwise, false. 既定値は、false です。The default is false.

実装

次のコード例では、選択したツリー TreeViewノードを1つから削除し、両方のツリーノードコレクションが読み取り専用でない場合は、それを別のツリーノードに追加します。The following code example removes the selected tree node from one TreeView and adds it to another if both tree node collections are not read-only. ButtonをクリックTreeView Insert TreeView Removeすると、 TreeView.SelectedNodeプロパティによって表されるがメソッドを使用して1つから削除され、メソッドを使用して別のに追加されます。TreeNodeWhen a Button is clicked, the TreeNode represented by the TreeView.SelectedNode property is deleted from one TreeView using the Remove method and added to the other TreeView using the Insert method. この例では、2つForm TreeViewのコントロールとButtonが含まれたが必要です。This example requires that you have a Form that contains two TreeView controls and a Button. コントロールTreeViewの名前treeView1はとtreeView2にする必要があります。The TreeView controls should be named treeView1 and treeView2.

void button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   // If neither TreeNodeCollection is read-only, move the
   // selected node from treeView1 to treeView2.
   if (  !treeView1->Nodes->IsReadOnly &&  !treeView2->Nodes->IsReadOnly )
   {
      if ( treeView1->SelectedNode != nullptr )
      {
         TreeNode^ tn = treeView1->SelectedNode;
         treeView1->Nodes->Remove( tn );
         treeView2->Nodes->Insert( treeView2->Nodes->Count, tn );
      }
   }
}
private void button1_Click(object sender, EventArgs e)
{
   // If neither TreeNodeCollection is read-only, move the 
   // selected node from treeView1 to treeView2.
   if(!treeView1.Nodes.IsReadOnly && !treeView2.Nodes.IsReadOnly)
   {
      if(treeView1.SelectedNode != null)
      {
         TreeNode tn = treeView1.SelectedNode;
         treeView1.Nodes.Remove(tn);
         treeView2.Nodes.Insert(treeView2.Nodes.Count, tn);
      }
   }
}
Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click
   ' If neither TreeNodeCollection is read-only, move the 
   ' selected node from treeView1 to treeView2. 
   If Not treeView1.Nodes.IsReadOnly And Not treeView2.Nodes.IsReadOnly Then
      If (treeView1.SelectedNode IsNot Nothing) Then
         Dim tn As TreeNode = treeView1.SelectedNode
         treeView1.Nodes.Remove(tn)
         treeView2.Nodes.Insert(treeView2.Nodes.Count, tn)
      End If
   End If
End Sub

適用対象