Trying to read the number of selected items in ChartListBox

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Dave
Advanced
Posts: 139
Joined: Mon Sep 22, 2008 12:00 am

Trying to read the number of selected items in ChartListBox

Post by Dave » Tue Feb 17, 2009 11:52 am

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?

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

Post by Yeray » Tue Feb 17, 2009 4:47 pm

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.
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

Post by Dave » Tue Feb 17, 2009 5:03 pm

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.

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

Post by Yeray » Wed Feb 18, 2009 8:59 am

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;
} 
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

Post by Dave » Wed Feb 18, 2009 4:28 pm

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;

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

Post by Yeray » Thu Feb 19, 2009 11:12 am

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();
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

Post by Dave » Thu Feb 19, 2009 4:31 pm

Thanks Yeray, Ive got it fixed now.

Post Reply