GetElementLevel Example for VB.NET

'LEADDICOM1 is a DICOM Dataset defined outside this method
Private Sub TestGetElementLevel()
   Dim x As Integer
   Dim lLevel As Integer

   'Navigate the Data Set as a List, not as a Tree
   'Move to the 20th element, and then find that element's level in the Tree
   LEADDICOM1.EnableMethodErrors = True
   On Error GoTo MOVEELEMENTERROR
   'move to first element in Data Set
   LEADDICOM1.MoveFirstElement(False)

   'move to the 20th element
   For x = 2 To 20
      LEADDICOM1.MoveNextElement(False)
   Next

   LEADDICOM1.FindTag(LEADDICOM1.CurrentElement.Tag)
   lLevel = LEADDICOM1.GetElementLevel
   MessageBox.Show("Element: " & LEADDICOM1.CurrentTag.Name & " at level " & CStr(lLevel))

   Exit Sub

MOVEELEMENTERROR:
   MessageBox.Show("Error")

End Sub