GetTimeValue 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 TestGetTimeValue()
{
   int lCount = 0;
   short nRet = 0;
   LEADDICOM1.EnableMethodErrors = false;
   //move to the root element
   LEADDICOM1.MoveFirstElement(false);
   LEADDICOM1.MoveRootElement();
   //insert a new element for the Time Value
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants2.TAG_PATIENT_BIRTH_TIME, (short)LTDICLib.DicomVRCodeConstants.VR_TM, false, 0);
   //insert an Time value into the element
   LEADDICOM1.TimeValueCount = 1;
   LEADDICOM1.get_TimeValues(0).Hours = 12;
   LEADDICOM1.get_TimeValues(0).Minutes = 25;
   LEADDICOM1.get_TimeValues(0).Seconds = 33;
   LEADDICOM1.get_TimeValues(0).Fractions = 50;
   //set the time
   nRet = LEADDICOM1.SetTimeValue(1);
   if (nRet != 0)
   {
      MessageBox.Show("Error");
      return;
   }
   LEADDICOM1.TimeValueCount = 0; //free the value
   Text1.Visible = true;
   Text1.Text = "";
   //get the value count
   lCount = LEADDICOM1.GetValueCount();
   MessageBox.Show("There are " + System.Convert.ToString(lCount) + " values!");
   //get the value
   nRet = LEADDICOM1.GetTimeValue(0, lCount);
   //display the value Text1.Text = "Hours: " + System.Convert.ToString(LEADDICOM1.get_TimeValues(0).Hours) + " Minutes: " + System.Convert.ToString(LEADDICOM1.get_TimeValues(0).Minutes + " Seconds: " + System.Convert.ToString(LEADDICOM1.get_TimeValues(0).Seconds) + " Fractions: " + System.Convert.ToString(LEADDICOM1.get_TimeValues(0).Fractions));
   LEADDICOM1.EnableMethodErrors = true;
   MessageBox.Show("wait");
}