Metodo ContextNode.ToString
Aggiornamento: novembre 2007
Restituisce un tipo di stringa leggibile per l'oggetto ContextNode.
Spazio dei nomi: System.Windows.Ink
Assembly: IAWinFX (in IAWinFX.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 illustrato un metodo che attraversa in modo ricorsivo una struttura ad albero di oggetti ContextNode. Viene utilizzata la proprietà SubNodes e viene popolato un oggetto TreeView tramite l'aggiunta di oggetti TreeViewItem. Quindi, viene impostata la proprietà Header su ToString e viene aggiunto InkWordNode.GetRecognizedString o InkDrawingNode.GetShapeName se necessario.
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);
}
}
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