How detect when series checkbox is selected in the legend?

TeeChart for ActiveX, COM and ASP
Post Reply
Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

How detect when series checkbox is selected in the legend?

Post by Dave » Fri Sep 19, 2014 1:04 pm

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!

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Fri Sep 19, 2014 3:42 pm

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
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

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

Post by Dave » Thu Sep 25, 2014 1:48 pm

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.

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Thu Sep 25, 2014 2:49 pm

Hi,

Here it is your thread in the .NET forum and the according reply:
http://www.teechart.net/support/viewtop ... =4&t=15196
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply