InsertUID Example for C#

//This example uses the predefined variable “ListView1” of type “ListView” from “.NET Framework”.
//LEADDICOM1 is a DICOM Dataset defined outside this method
private void TestInsertUID()
{
   try
   {
      short nRet = 0;
      ListViewItem ItemX = null;
      LEADDICOM1.EnableMethodErrors = false;
      nRet = LEADDICOM1.FindUID("1.2.840.10008.1.3");
      if (nRet == 0)
      {
         MessageBox.Show("Already Exists!");
         return;
      }
      LEADDICOM1.EnableMethodErrors = true;
      nRet = LEADDICOM1.InsertUID("1.2.840.10008.1.3", "My Test UID", (int)LTDICLib.DicomUIDTypes.DICOM_UID_TYPE_OTHER);
      if (nRet != 0)
         MessageBox.Show("Error");
      //add item to the ListView control
      ItemX = new ListViewItem();
      ListView1.Items.Add(ItemX);
      ItemX.Text = System.Convert.ToString(LEADDICOM1.get_CurrentUID().Code);
      ItemX.SubItems.Add(LEADDICOM1.get_CurrentUID().Name);
      ItemX.Selected = true;
      ListView1.Refresh();
      ListView1.Focus();
      LEADDICOM1.EnableMethodErrors = true;
      return;
   }
   catch
   {
      MessageBox.Show("Error");
   }
}