1 Reply Latest reply on Jul 20, 2018 2:06 PM by gregor

    How to know which trace is hide


      I have two trends (trend1 and trend2) in PIProcessBook.

      Both Trends are "sincronized" with VBA, this means that they have the same tags, the same colors and the same scale for each tag. The only difference is the time of both.

      What I want to do is, when a user clicks on "Trend1" and hides a trace, I want to hide the same trace, but on the "Trend2".

      How can I get the trace number that the user clicks to hide it?


      Another option is to copy ALL the trace state (show/hide) to the Trend2, everytime the user clicks on the Trend1. How can I do this?




        • Re: How to know which trace is hide

          Hello Mario,


          Please try this:


          Private Sub CommandButton1_Click()
              Dim iT1 As Integer
              Dim iT2 As Integer
              iT1 = Trend1.TraceCount
              iT2 = Trend2.TraceCount
              Dim bTrace As Boolean
              If iT1 <> iT2 Then
                  MsgBox "Trace is different between Trend1 (" & Str(iT1) & ") and Trend2 (" & Str(iT2) & ")."
                  Exit Sub
              End If
              For i = 1 To iT1
                  Trend2.CurrentTrace = i
                  Trend1.CurrentTrace = i
                  bTrace = Trend1.ShowTrace
                  Trend2.ShowTrace = bTrace
          End Sub


          Edit: I misread your question the first time. Sorry. I tried to get the index of the Trace a user clicked but it looks as if Trend.CurrentTrace is not affected by clicking a Trace. You should however be able to accomplish what you like by iterating through Traces and assign the value of the ShowTrace property from Trend1 to Trace2 in the Trend1_Click event with code similar to what I've posted above.