InsertVR Example for Delphi

var
   nRet: Integer;
   ItemX: TListItem;
   nCode: Integer;
   nRestrict: Integer;
begin
   LEADDicomDS1.EnableMethodErrors:= True;
   LEADDicomDS1.EnableMethodErrors:= False;
   nCode:= 20322;
   nRet:= LEADDicomDS1.FindVR (nCode);
   if(nRet = 0)then
   begin
      ShowMessage('Already Exists!');
      Exit;
   end;

   nRestrict:= DICOM_VR_FIXED + DICOM_VR_TEXT;
   nRet:= LEADDicomDS1.InsertVR(nCode, 'My Test VR', 64, nRestrict, 1);
   if(nRet <> 0)then
   begin
      ShowMessage('Error');
      Exit;
   end;
   //add item to the ListView control
   ItemX:= ListView1.Items.Add();

   ItemX.Caption:= IntToStr(LEADDicomDS1.DefaultInterface.Get_CurrentVR ().Code);
   ItemX.SubItems[1]:= LEADDicomDS1.DefaultInterface.Get_CurrentVR().Name;
   ItemX.SubItems[2]:= IntToStr(LEADDicomDS1.DefaultInterface.Get_CurrentVR().Length);
   ItemX.SubItems[3]:= IntToStr(LEADDicomDS1.DefaultInterface.Get_CurrentVR().Restrict);
   ItemX.SubItems[4]:= IntToStr(LEADDicomDS1.DefaultInterface.Get_CurrentVR().UnitSize);
    
   ListView1.Selected:= ItemX;
   ListView1.Refresh();
   ListView1.SetFocus();

   LEADDicomDS1.EnableMethodErrors:= True;
end;