Page 1 of 1

Unhandled exception inDemo application

Posted: Tue Aug 03, 2010 12:52 am
by 15654268
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

Re: Unhandled exception inDemo application

Posted: Tue Aug 03, 2010 9:05 am
by 10050769
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,

Re: Unhandled exception inDemo application

Posted: Fri Dec 31, 2010 10:12 pm
by 15654268
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.

Re: Unhandled exception inDemo application

Posted: Mon Jan 03, 2011 12:32 pm
by 10050769
Hello Capell.

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

Thanks,