Recent

Author Topic: [solved] How to hide/show series in a TChartListBox?  (Read 1435 times)

Muso

  • Sr. Member
  • ****
  • Posts: 347
[solved] How to hide/show series in a TChartListBox?
« on: February 21, 2022, 08:02:12 pm »
I have a chart with many series. The user should can hide/show them in the chart, but he should also be able to filter series to select them for certain purposes.

Therefore I have a TChartListBox in a dialog. When the user presses in the dialog a button, then for example only series with the name "Start_XXX" should be shown in the TChartListBox. This visibility change should only happen in the TChartListBox, not in the chart.

Is this possible and if so, how?
« Last Edit: February 22, 2022, 11:31:11 pm by Muso »

wp

  • Hero Member
  • *****
  • Posts: 10060
Re: How to hide/show series in a TChartListBox?
« Reply #1 on: February 21, 2022, 09:52:17 pm »
The chartlistbox is re-populated at a variety of occasions. Whenever this happens events OnAddSeries are fired before a series is added to the listbox. These events have a boolean parameter Skip which you can set to true if you want to avoid having this series in the listbox.

Muso

  • Sr. Member
  • ****
  • Posts: 347
Re: How to hide/show series in a TChartListBox?
« Reply #2 on: February 22, 2022, 01:58:50 pm »
These events have a boolean parameter Skip which you can set to true if you want to avoid having this series in the listbox.

I use the method already. But the use case here is that OnAddSeries is not triggered. I open a dialog containing the TChartListBox and depending on the settings the user do in this dialog, the TChartListBox should display certain series. The connected chart should not be changed. Therefore I need a way to show/hide series in this particular TChartListBox without touching the chart, meaning OnAddSeries will not fire.

wp

  • Hero Member
  • *****
  • Posts: 10060
Re: How to hide/show series in a TChartListBox?
« Reply #3 on: February 22, 2022, 04:34:04 pm »
You can manually re-populate the listbox by calling the TChartListBox method Populate()(. See attached demo.

Muso

  • Sr. Member
  • ****
  • Posts: 347
Re: How to hide/show series in a TChartListBox?
« Reply #4 on: February 22, 2022, 11:30:51 pm »
You can manually re-populate the listbox by calling the TChartListBox method Populate()(. See attached demo.

Many thanks! Populate was what I was looking for. This works fine.

 

TinyPortal © 2005-2018