GetStringValue Example for C#

//This example uses the predefined variable “Text5” of type “TextBox” from “.NET Framework”.
//LEADDICOM1 is a DICOM Dataset defined outside this method
private void TestGetStringValue()
{
   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 String Values
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants1.TAG_IMAGE_TYPE, (short)LTDICLib.DicomVRCodeConstants.VR_CS, false, 0);
   //insert some string values into the element
   LEADDICOM1.StringValueCount = 5;
   for (x = 0; x < 5; x++)
   {
      LEADDICOM1.set_StringValues(x, "String #" + System.Convert.ToString(x + 1));
   }
   //set the strings
   nRet = LEADDICOM1.SetStringValue(5);
   if (nRet != 0)
   {
      MessageBox.Show("Error");
      return;
   }
   LEADDICOM1.StringValueCount = 0; //free the values
   Text5.Visible = true;
   Text5.Text = "";
   //get the value count
   lCount = LEADDICOM1.GetValueCount();
   MessageBox.Show("There are " + System.Convert.ToString(lCount) + " values!");
   //get the values
   nRet = LEADDICOM1.GetStringValue(0, lCount);
   if (nRet == 0)
   {
      for (x = 0; x < LEADDICOM1.StringValueCount; x++)
      {
         //display each value separated on a separate line
         Text5.Text = Text5.Text + '\r' + '\n' + System.Convert.ToString(LEADDICOM1.get_StringValues(x));
      }
   }
   LEADDICOM1.EnableMethodErrors = true; MessageBox.Show("wait");
}