FindFirstElement 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 TestFindFirstElement()
   'Find the first image element and display it
   LEADDICOM1.EnableMethodErrors = True
   On Error GoTo MOVEELEMENTERROR
   'move to first element in Data Set
   LEADDICOM1.MoveFirstElement(False)

   LEADDICOM1.FindFirstElement(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.FindNextElement(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