MoveRootElement Example for VB.NET
'LEADDICOM1 is a DICOM Dataset defined outside this method
Private Sub TestMoveRootElement()
Dim nRet1 As Short
Dim nRet2 As Short
LEADDICOM1.EnableMethodErrors = True
On Error GoTo MOVEELEMENTERROR
'move to first element in Data Set
LEADDICOM1.MoveFirstElement(False)
LEADDICOM1.FindTag(LEADDICOM1.CurrentElement.Tag)
MessageBox.Show("Element: " & LEADDICOM1.CurrentTag.Name)
'move to next element in the same level of the Data Set
LEADDICOM1.MoveNextElement(True)
LEADDICOM1.FindTag(LEADDICOM1.CurrentElement.Tag)
MessageBox.Show("Element: " & LEADDICOM1.CurrentTag.Name)
'move to last element in the same level of the Data Set
LEADDICOM1.MoveLastElement(True)
LEADDICOM1.FindTag(LEADDICOM1.CurrentElement.Tag)
MessageBox.Show("Element: " & LEADDICOM1.CurrentTag.Name)
'move to previous element in the same level of the Data Set
LEADDICOM1.MovePrevElement(True)
LEADDICOM1.FindTag(LEADDICOM1.CurrentElement.Tag)
MessageBox.Show("Element: " & LEADDICOM1.CurrentTag.Name)
'find the first element that has a child
LEADDICOM1.EnableMethodErrors = False
nRet1 = LEADDICOM1.MoveFirstElement(False)
While nRet1 = 0
nRet2 = LEADDICOM1.MoveChildElement
If (nRet2 = 0) Then
LEADDICOM1.FindTag(LEADDICOM1.CurrentElement.Tag)
MessageBox.Show("Element: " & LEADDICOM1.CurrentTag.Name)
nRet1 = 1
'end
loop
End If
If (nRet1 <> 1) Then
'check next element in this same level
nRet1 = LEADDICOM1.MoveNextElement(True)
End If
End While
LEADDICOM1.EnableMethodErrors = True
'move back to the element's parent
If (nRet1 = 1) Then
LEADDICOM1.MoveParentElement()
LEADDICOM1.FindTag(LEADDICOM1.CurrentElement.Tag)
MessageBox.Show("Element: " & LEADDICOM1.CurrentTag.Name)
End If
Exit Sub
MOVEELEMENTERROR:
MessageBox.Show("Error")
End Sub