Unhandled exception inDemo application

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Captell
Newbie
Newbie
Posts: 65
Joined: Fri Sep 18, 2009 12:00 am

Unhandled exception inDemo application

Post by Captell » Tue Aug 03, 2010 12:52 am

Using the TeeChart for .Net Examples demo for version 4.0.201027960.
if you go to Welcome !\New in Series\Marks on Bar
and change the Sont Size: to 0 an unhandled exception is thrown
Adrian Heald
Director
ITSM Reporting Services Pty Ltd
http://www.reportingservices.com

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Unhandled exception inDemo application

Post by Sandra » Tue Aug 03, 2010 9:05 am

Hello Captell,

It is not a bug of TeeChart code, is exception of WinForms. It appears because, value of '0' is not valid for variable 'emSize'. 'emSize' should be greater than 0 and less than or equal to System.Single.MaxValue. See next code, that reproduce exception, using simple code without TeeChart.Net component.

Code: Select all

public Form1()
        {
            InitializeComponent();
            Initialize();
        }
        private void Initialize()
        {
            ComboBox ComboBox1 = new ComboBox();
            this.Controls.Add(ComboBox1);
            ComboBox1.Items.AddRange(new object[] { "bigger","smaller"});
            ComboBox1.SelectedIndex = 0;
            //ComboBox1.
            label1.Text = "Test 1";
            ComboBox1.SelectedIndexChanged +=new EventHandler(ComboBox1_SelectedIndexChanged);

        }
        private void ComboBox1_SelectedIndexChanged(System.Object sender,System.EventArgs e)
        {

            // Cast the sender object back to a ComboBox.
            ComboBox ComboBox1 = (ComboBox)sender;

            // Retrieve the selected item.
            string selectedString = (string)ComboBox1.SelectedItem;

            // Convert it to lowercase.
            selectedString = selectedString.ToLower();

            // Declare the current size.
            float currentSize;

            // Switch on the selected item. 
            switch (selectedString)
            {

                // If Bigger is selected, get the current size from the 
                // Size property and increase it. Reset the font to the
                //  new size, using the current unit.
                case "bigger":
                    currentSize = label1.Font.Size;
                    currentSize += 2.0F;
                    label1.Font = new Font(label1.Font.Name, currentSize,
                        label1.Font.Style, label1.Font.Unit);

                    // If Smaller is selected, get the current size, in points,
                    // and decrease it by 1.  Reset the font with the new size
                    // in points.
                    break;
                case "smaller":
                    currentSize = label1.Font.SizeInPoints;
                    currentSize = 0;
                    label1.Font = new Font(label1.Font.Name, currentSize,
                        label1.Font.Style);
                    break;
            }
        }
Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Captell
Newbie
Newbie
Posts: 65
Joined: Fri Sep 18, 2009 12:00 am

Re: Unhandled exception inDemo application

Post by Captell » Fri Dec 31, 2010 10:12 pm

I understand that, I only point it out because it looks bad for tchart demo to be craching. It is a bug in tchart code in that your code in the demo should be handeling the exception properly.
Adrian Heald
Director
ITSM Reporting Services Pty Ltd
http://www.reportingservices.com

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Unhandled exception inDemo application

Post by Sandra » Mon Jan 03, 2011 12:32 pm

Hello Capell.

I inform you that this is already solved for next version of TeeChart.Net.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply