MoveRootElement Example for C#

//LEADDICOM1 is a DICOM Dataset defined outside this method
private void TestMoveRootElement ( )
{
   try
   {
      short nRet1 = 0;
      short nRet2 = 0;
      LEADDICOM1.EnableMethodErrors = true;

      //move to first element in Data Set
      LEADDICOM1.MoveFirstElement(false);
      LEADDICOM1.FindTag(LEADDICOM1.get_CurrentElement().Tag);
      MessageBox.Show("Element: " + LEADDICOM1.get_CurrentTag().Name);

      //move to next element in the same level of the Data Set
      LEADDICOM1.MoveNextElement(true);
      LEADDICOM1.FindTag(LEADDICOM1.get_CurrentElement().Tag);
      MessageBox.Show("Element: " + LEADDICOM1.get_CurrentTag().Name);

      //move to last element in the same level of the Data Set
      LEADDICOM1.MoveLastElement(true);
      LEADDICOM1.FindTag(LEADDICOM1.get_CurrentElement().Tag);
      MessageBox.Show("Element: " + LEADDICOM1.get_CurrentTag().Name);

      //move to previous element in the same level of the Data Set
      LEADDICOM1.MovePrevElement(true);
      LEADDICOM1.FindTag(LEADDICOM1.get_CurrentElement().Tag);
      MessageBox.Show("Element: " + LEADDICOM1.get_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)
         {
            LEADDICOM1.FindTag(LEADDICOM1.get_CurrentElement().Tag);
            MessageBox.Show("Element: " + LEADDICOM1.get_CurrentTag().Name);
            nRet1 = 1; //end loop
         }
         if (nRet1 != 1)
         {
            //check next element in this same level
            nRet1 = LEADDICOM1.MoveNextElement(true);
         }
      }
      LEADDICOM1.EnableMethodErrors = true;
      //move back to the element's parent
      if (nRet1 == 1)
      {
         LEADDICOM1.MoveParentElement();
         LEADDICOM1.FindTag(LEADDICOM1.get_CurrentElement().Tag);
         MessageBox.Show("Element: " + LEADDICOM1.get_CurrentTag().Name);
      }
      return;
   }
   catch
   {
      MessageBox.Show("Error");
   }
}