共用方式為


ContextNode.ToString 方法

以字串的形式傳回 ContextNode 物件的型別,這個型別是人們可讀取的 (Human-Readable) 型別。

命名空間:  System.Windows.Ink
組件:  IAWinFX (在 IAWinFX.dll 中)

語法

'宣告
Public Overrides Function ToString As String
'用途
Dim instance As ContextNode
Dim returnValue As String

returnValue = instance.ToString()
public override string ToString()
public:
virtual String^ ToString() override
public String ToString()
public override function ToString() : String

傳回值

型別:System.String
ContextNode 物件的型別,這個型別是人們可讀取的字串型別。

備註

例如,TypeInkWord,則這個方法會傳回 "InkWordNode" 這個值。

範例

這個範例是一個方法,會遞迴地周遊 ContextNode 物件的樹狀目錄。它會使用 SubNodes 屬性,並藉由加入 TreeViewItem 物件來填入 TreeView。然後將物件的 Header 屬性設定為 ToString,並加入 InkWordNode.GetRecognizedStringInkDrawingNode.GetShapeName (如果適用的話)。

Private Shared Sub WalkTree(ByVal parentContextNode As ContextNode, ByVal parentTreeNode As TreeViewItem) 

    parentTreeNode.IsExpanded = True

    For Each theContextSubnode As ContextNode In parentContextNode.SubNodes
        Dim newTreeNode As New TreeViewItem()
        newTreeNode.Header = theContextSubnode.ToString()

        If TypeOf theContextSubnode Is InkWordNode Then
            newTreeNode.Header += ": " + CType(theContextSubnode, InkWordNode).GetRecognizedString()
        ElseIf TypeOf theContextSubnode Is InkDrawingNode Then
            newTreeNode.Header += ": " + CType(theContextSubnode, InkDrawingNode).GetShapeName()
        End If

        ' If the context node is confirmed, add a note to the
        ' tree view item.
        If (theContextSubnode.IsConfirmed(ConfirmationType.NodeTypeAndProperties)) Then

            newTreeNode.Header += " Confirmed."
        End If


        ' Add the context node as a tag of the tree view item and
        ' add the new tree view item to the parent node.
        newTreeNode.Tag = theContextSubnode
        parentTreeNode.Items.Add(newTreeNode)

        WalkTree(theContextSubnode, newTreeNode)
    Next theContextSubnode

End Sub 'WalkTree
private static void WalkTree(ContextNode parentContextNode, TreeViewItem parentTreeNode)
{
    // Expand the current TreeViewItem.
    parentTreeNode.IsExpanded = true;

    foreach (ContextNode theContextSubnode
        in parentContextNode.SubNodes)
    {
        TreeViewItem newTreeNode = new TreeViewItem();
        newTreeNode.Header = theContextSubnode.ToString();

        if (theContextSubnode is InkWordNode)
        {
            newTreeNode.Header += ": " +
                ((InkWordNode)theContextSubnode).GetRecognizedString();
        }
        else if (theContextSubnode is InkDrawingNode)
        {
            newTreeNode.Header += ": " +
                ((InkDrawingNode)theContextSubnode).GetShapeName();
        }

        // If the context node is confirmed, add a note to the
        // tree view item.
        if (theContextSubnode.IsConfirmed(ConfirmationType.NodeTypeAndProperties))
        {
            newTreeNode.Header += " Confirmed.";
        }

        // Add the context node as a tag of the tree view item and
        // add the new tree view item to the parent node.
        newTreeNode.Tag = theContextSubnode;
        parentTreeNode.Items.Add(newTreeNode);

        WalkTree(theContextSubnode, newTreeNode);
    }
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Framework

支援版本:3.0

請參閱

參考

ContextNode 類別

ContextNode 成員

System.Windows.Ink 命名空間