Page 1 of 1

How detect when series checkbox is selected in the legend?

Posted: Fri Sep 19, 2014 1:04 pm
by 13050364
Hi

To display the checkboxes beside each series in the legend i do this;

theChart.Legend.CheckBoxes = true;


If the user selects a checkbox how do I detect this??

Thanks!

Re: How detect when series checkbox is selected in the legend?

Posted: Fri Sep 19, 2014 3:42 pm
by yeray
Hello,

You can use the OnClickLegend event as follows:

Code: Select all

Private Sub TChart1_OnClickLegend(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  Dim i As Integer
  Dim tmpX As Integer
  Dim tmpY As Integer
  If TChart1.Legend.CheckBoxes Then
    tmpX = TChart1.Legend.Left + 5
    For i = 0 To TChart1.SeriesCount - 1
      tmpY = TChart1.Legend.Item(i).Top + 2
      If (X >= tmpX) And (X <= tmpX + 10) And (Y >= tmpY) And (Y <= tmpY + 10) Then
        MsgBox "Checkbox for Series " + Str$(i) + " clicked"
      End If
    Next i
  End If
End Sub

Re: How detect when series checkbox is selected in the legend?

Posted: Thu Sep 25, 2014 1:48 pm
by 13050364
Thanks Yeray. But unless Im mistake this code does not show whether a box is selected or deselected?

BTW. I meant to post this question on the .NET thread. So I will post there and link to your reply.

Re: How detect when series checkbox is selected in the legend?

Posted: Thu Sep 25, 2014 2:49 pm
by yeray
Hi,

Here it is your thread in the .NET forum and the according reply:
http://www.teechart.net/support/viewtop ... =4&t=15196