TreeView.SelectedItem 属性

定义

获取 TreeView 中的选定项。

public:
 property System::Object ^ SelectedItem { System::Object ^ get(); };
[System.ComponentModel.Bindable(true)]
public object SelectedItem { get; }
[<System.ComponentModel.Bindable(true)>]
member this.SelectedItem : obj
Public ReadOnly Property SelectedItem As Object

属性值

Object

TreeView 中的选定对象;如果没有选定任何项,则为 null。 默认值是 null

属性

示例

以下示例演示如何获取属性的值 SelectedItem

TreeViewItem selectedTVI = (TreeViewItem)myTreeView.SelectedItem;
Dim selectedTVI As TreeViewItem = CType(myTreeView.SelectedItem, TreeViewItem)

注解

The SelectedItem property on the TreeView control is a read-only property and is set to an item when the IsSelected property value of the item TreeView is set to true.

依赖项属性信息

标识符字段 SelectedItemProperty
元数据属性设置为 true

适用于

另请参阅