Page 1 of 1

Trying to read the number of selected items in ChartListBox

Posted: Tue Feb 17, 2009 11:52 am
by 13050364
Hi

Ive added several charts to the chart list box called ChartListbox1

eg. public Steema.TeeChart.ChartListBox chartListBox1;

Im trying to read how many charts have been selected. So Ive tried both of the following.

int a = theController.chartListBox1.SelectedIndices.Count;
int b = theController.chartListBox1.SelectedItems.Count;


However a and b are only ever set to 1 even when I have 3 charts selected.

Am I reading the correct properties?

Posted: Tue Feb 17, 2009 4:47 pm
by yeray
Hi Dave,

We aren't sure to understand what are you exactly trying to do here.
Please, could you send us a simple example project we can run "as-is" to reproduce the problem here?
You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Posted: Tue Feb 17, 2009 5:03 pm
by 13050364
Yeray

I could do that but may take some time. Perhaps I can try explaining again.

I have a ChartListBox control that displays a list (of Series) with checkboxes beside each. I just want to be able to count how many checkboxes are Checked. When the checkbox is checked the series is displayed on the Chart. So there can be say 1-10 series diplayed on the chart.

If you need more info let me know.

Posted: Wed Feb 18, 2009 8:59 am
by yeray
Hi Dave,

You could count the active series as follows:

Code: Select all

int total = 0;

for (int i = 0; i < chartListBox1.Items.Count; i++)
{
   if (chartListBox1.Series(i).Active)
   total += 1;
} 

Posted: Wed Feb 18, 2009 4:28 pm
by 13050364
Yeray

Thanks. Im still not getting the result I expect though. When I check/uncheck the checkboxes at runtime there is no change in "total".

Can you explain what the following 2 statements do? Thanks.

int b = chartListBox1.SelectedIndices.Count;
int a = chartListBox1.SelectedItems.Count;

Posted: Thu Feb 19, 2009 11:12 am
by yeray
Hi Dave,

ChartListBox inherits from .NET framework's system.windows.forms.listbox. You can see SelectedIndices and SelectedItems explanations and examples at msdn.

Maybe, if you are doing some changes and you want to force the chart to update internal calculations:

Code: Select all

tChart1.Refresh();

Posted: Thu Feb 19, 2009 4:31 pm
by 13050364
Thanks Yeray, Ive got it fixed now.