ContextNode.SubNodes 属性
获取 ContextNode 对象的直接子级。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)
语法
声明
Public ReadOnly Property SubNodes As ContextNodeCollection
用法
Dim instance As ContextNode
Dim value As ContextNodeCollection
value = instance.SubNodes
public ContextNodeCollection SubNodes { get; }
public:
property ContextNodeCollection^ SubNodes {
ContextNodeCollection^ get ();
}
/** @property */
public ContextNodeCollection get_SubNodes()
public function get SubNodes () : ContextNodeCollection
属性值
类型:Microsoft.Ink.ContextNodeCollection
ContextNode 对象的直接子级。
备注
此属性只返回直接子级,而不是所有后代。
示例
此示例演示的方法递归遍历一个 ContextNode 对象树。示例中使用了 SubNodes 属性,并通过添加 TreeNode 对象填充 System.Windows.Forms.TreeView。然后,将这些树节点的 Text 属性设置为 GetRecognizedString。
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;
}
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0