GetShortValue Example for C#

//This example uses the predefined variable “Text1” of type “TextBox” from “.NET Framework”.
//LEADDICOM1 is a DICOM Dataset defined outside this method
private void TestGetShortValue()
{
   int lCount = 0;
   int x = 0;
   short nRet = 0;
   LEADDICOM1.EnableMethodErrors = false;
   //move to the root element
   LEADDICOM1.MoveFirstElement(false);
   LEADDICOM1.MoveRootElement();
   //insert a new element for the Short Values
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants1.TAG_RECORD_IN_USE_FLAG, (short)LTDICLib.DicomVRCodeConstants.VR_US, false, 0);
   Text1.Visible = true;
   Text1.Text = "";
   //insert some short values into the element
   LEADDICOM1.ShortValueCount = 5;
   for (x = 0; x < 5; x++)
   {
      LEADDICOM1.set_ShortValues(x, (short) (x * 100));
   }
   //set the shorts
   nRet = LEADDICOM1.SetShortValue(5);
   if (nRet != 0)
   {
      MessageBox.Show("Error");
      return;
   }
   LEADDICOM1.ShortValueCount = 0;
   //free the values
   //get the value count
   lCount = LEADDICOM1.GetValueCount();
   MessageBox.Show("There are " + System.Convert.ToString(lCount) + " values!");
   //get the values
   nRet = LEADDICOM1.GetShortValue(0, lCount);
   if (nRet == 0)
   {
      for (x = 0; x < LEADDICOM1.ShortValueCount; x++)
      {
         //display each value separated by a " X "
         Text1.Text = Text1.Text + " X " + System.Convert.ToString(LEADDICOM1.get_ShortValues(x));
      }
   }
   MessageBox.Show("wait");
   LEADDICOM1.EnableMethodErrors = true;
}