0

Update Value Boxes based on Time/Date

I have an application that will show current line conditions/settings and whether they are running in spec. We want to add a way to pick a time/date so we can see all those line conditions on a certain day/app on the app. Is there an easy way to do this, or would that require scripting with the date time picker?

3 replies

null
    • smason
    • 4 wk ago
    • Reported - view

    Hi ,

    This script will update a ValueBox using the DateTime Picker.

            public void DateTimePicker1_OnDateTimeChange(object sender, DateTime dateTime)
            {
                string startTime = dateTime.ToString("o");
                ValueBox1.AggregateStartTime = startTime;
            }

      • nicholas_portz
      • 4 wk ago
      • Reported - view

       There is a lot of Value Boxes on the specific app page, is there a way to edit the script so it updates every value box in case we decide we add more in the future, or will I have to make a line in the script for every value box?

      • smason
      • 3 wk ago
      • Reported - view

      With a little bit of help from Chat GPT and a developer, I think I got something that will work for you. Try this and see:

      public void DateTimePicker1_OnDateTimeChange(object sender, DateTime dateTime)
      {
          string startTime = dateTime.ToString("o");
      
          // Iterate through all controls on the screen
          foreach (var control in Screen.ScreenControls)
          {
              // Check if the control is a ValueBox
              if (control is ControlValueBox valueBox)
              {
                  valueBox.AggregateStartTime = startTime;
              }
          }
      }
      

Content aside

print this pagePrint this page
  • 3 wk agoLast active
  • 3Replies
  • 22Views
  • 2 Following