FindLastElement Example for VB.NET

'LEADDICOM1 is a DICOM Dataset defined outside this method
'This example uses the predefined variable "LEADRasterView1" of type "AxLEADRasterView" from "LEADTOOLS Toolkit".
Private Sub TestFindLastElement()
   'Find the last image element and display it
   LEADDICOM1.EnableMethodErrors = True
   On Error GoTo MOVEELEMENTERROR
   'move to last element in Data Set
   LEADDICOM1.MoveLastElement(False)

   LEADDICOM1.FindLastElement(LTDICLib.DicomDataSetTagConstants9.TAG_PIXEL_DATA, False)
   LEADDICOM1.GetBitmapValue(0, 0, LTDICLib.DicomColorOrderConstants.ORDER_RGB, 0)
   LEADRasterView1.Raster.Bitmap = LEADDICOM1.Bitmap
   LEADDICOM1.Bitmap = 0
   LEADDICOM1.FindTag(LEADDICOM1.CurrentElement.Tag)
   MessageBox.Show("Element: " & LEADDICOM1.CurrentTag.Name)

   'find each image
   While (True)
      LEADDICOM1.FindPrevElement(False)
      LEADDICOM1.GetBitmapValue(0, 0, LTDICLib.DicomColorOrderConstants.ORDER_RGB, 0)
      LEADRasterView1.Raster.Bitmap = LEADDICOM1.Bitmap
      LEADDICOM1.Bitmap = 0
      LEADDICOM1.FindTag(LEADDICOM1.CurrentElement.Tag)
      MessageBox.Show("Element: " & LEADDICOM1.CurrentTag.Name)
   End While

MOVEELEMENTERROR:
   MessageBox.Show("No More Images")

End Sub