本文整理汇总了VB.NET中System.Web.UI.IHierarchicalEnumerable.GetHierarchyData方法的典型用法代码示例。如果您正苦于以下问题:VB.NET IHierarchicalEnumerable.GetHierarchyData方法的具体用法?VB.NET IHierarchicalEnumerable.GetHierarchyData怎么用?VB.NET IHierarchicalEnumerable.GetHierarchyData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.IHierarchicalEnumerable
的用法示例。
在下文中一共展示了IHierarchicalEnumerable.GetHierarchyData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: RecurseDataBindInternal
Private Sub RecurseDataBindInternal(ByVal node As TreeNode, _
ByVal enumerable As IHierarchicalEnumerable, _
ByVal depth As Integer)
Dim item As Object
For Each item In enumerable
Dim data As IHierarchyData = enumerable.GetHierarchyData(item)
If Not data Is Nothing Then
' Create an object that represents the bound data
' to the control.
Dim newNode As New TreeNode()
Dim rvnode As New RootViewNode()
rvnode.Node = newNode
rvnode.Depth = depth
' The dataItem is not just a string, but potentially
' an XML node or some other container.
' If DataTextField is set, use it to determine which
' field to render. Otherwise, use the first field.
If DataTextField.Length > 0 Then
newNode.Text = DataBinder.GetPropertyValue _
(data, DataTextField, Nothing)
Else
Dim props As PropertyDescriptorCollection = _
TypeDescriptor.GetProperties(data)
' Set the "default" value of the node.
newNode.Text = String.Empty
' Set the true data-bound value of the TextBox,
' if possible.
If props.Count >= 1 Then
If Not props(0).GetValue(data) Is Nothing Then
newNode.Text = props(0).GetValue(data).ToString()
End If
End If
End If
Nodes.Add(rvnode)
If data.HasChildren Then
Dim newEnumerable As IHierarchicalEnumerable = _
data.GetChildren()
If Not (newEnumerable Is Nothing) Then
RecurseDataBindInternal(newNode, _
newEnumerable, depth + 1)
End If
End If
If MaxDepth < depth Then
MaxDepth = depth
End If
End If
Next item
End Sub