Condividi tramite


Metodo ContextNode.ToString

Aggiornamento: novembre 2007

Restituisce un tipo di stringa leggibile per l'oggetto ContextNode.

Spazio dei nomi:  Microsoft.Ink
Assembly:  Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.dll)

Sintassi

'Dichiarazione
Public Overrides Function ToString As String
'Utilizzo
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

Valore restituito

Tipo: System.String
Tipo di stringa leggibile per l'oggetto ContextNode.

Note

Ad esempio, se Type è InkWord, questo metodo restituisce il valore "InkWordNode".

Esempi

In questo esempio viene utilizzato un metodo che attraversa in modo ricorsivo una struttura ad albero di oggetti ContextNode. Viene utilizza la proprietà SubNodes e viene compilato un oggetto System.Windows.Forms.TreeView aggiungendo oggetti TreeNode. Viene quindi impostata al proprietà TreeNode.Text su ToString, aggiungendo InkWordNode.GetRecognizedString o InkDrawingNode.GetShapeName se appropriato.

Private Sub WalkTree(ByVal parentContextNode As Microsoft.Ink.ContextNode, _
                     ByVal parentTreeNode As TreeNode)

    Dim cNode As ContextNode
    For Each cNode In parentContextNode.SubNodes
        Dim newTNode As New TreeNode(cNode.ToString())
        If TypeOf cNode Is Microsoft.Ink.InkWordNode Then
            newTNode.Text = newTNode.Text + _
                ": " + CType(cNode, InkWordNode).GetRecognizedString()
        ElseIf TypeOf cNode Is Microsoft.Ink.InkDrawingNode Then
            Dim shapeName As String = CType(cNode, InkDrawingNode).GetShapeName()
            If shapeName <> "" Then
                newTNode.Text = newTNode.Text + ": " + shapeName
            End If
        End If
        WalkTree(cNode, newTNode)
        parentTreeNode.Nodes.Add(newTNode)

        ' Add the context node as a tag of the tree node
        newTNode.Tag = cNode
    Next cNode

End Sub 'WalkTree
        private void WalkTree(ContextNode parentContextNode, TreeNode parentTreeNode)
        {
            foreach (ContextNode cNode in parentContextNode.SubNodes)
            {
                TreeNode newTNode = new TreeNode(cNode.ToString());
                if (cNode is Microsoft.Ink.InkWordNode)
                {
                    newTNode.Text +=
                        ": " + ((InkWordNode)cNode).GetRecognizedString();
                }
                else if (cNode is Microsoft.Ink.InkDrawingNode)
                {
                    String shapeName = ((InkDrawingNode)cNode).GetShapeName();
                    if (shapeName != "")
                        newTNode.Text += ": " + shapeName;
                }
                WalkTree(cNode, newTNode);
                parentTreeNode.Nodes.Add(newTNode);

                // Add the context node as a tag of the tree node
                newTNode.Tag = cNode;
            }
        }

Piattaforme

Windows Vista

.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.

Informazioni sulla versione

.NET Framework

Supportato in: 3.0

Vedere anche

Riferimenti

ContextNode Classe

Membri ContextNode

Spazio dei nomi Microsoft.Ink