Profile Picture

Problem with series.Tags

Posted By Alexander Haberl 10 Years Ago
Author
Message
Alexander Haberl
Problem Posted 10 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 15, Visits: 48
Hi!
I switched to Version 2014.1 (full version number: 14.4.11.12), and suddenly I got problems with this code (which worked perfectly in 2012.1:
selectedSeries.Tags[cntSelected] = dataRow;
It throws a null reference exception.
I changed the line to
selectedSeries.Tags.Add(cntSelected, dataRow);
then it worked, but when I want to redraw my chart and call
selectedSeries.ClearDataPoints(); I again get a null reference exception. When I don't set a Tag at all, everything works fine.
Here's the complete code which sets the chart (I left out some irrelevant parts):
        private void SetChart(bool setCostFunction)
        {
            selectedSeries.ClearDataPoints();
            unselectedSeries.ClearDataPoints();

            costfunctionSeries.ClearDataPoints();
            lowerConfidenceIntervalSeries.ClearDataPoints();
            upperConfidenceIntervalSeries.ClearDataPoints();

            double maxXVal = Double.MinValue;

            //Add all Baggerungen that are in the list:
            List<double> xVals = new List<double>();
            List<double> yVals = new List<double>();

            int cntSelected = 0;
            int cntUnSelected = 0;

            foreach (DataGridViewRow row in dgvOverview.Rows)
            {
                //Only add if nettosumme and Kubatur are present!
                DataRowView drv = (DataRowView)row.DataBoundItem;
                var dataRow = (WAMSDataSet.VwBaggerungOverviewRow)drv.Row;

                if (!dataRow.IsKubaturNull() && !dataRow.IsNettosummeNull())
                {
                    //Add to Lists:
                    xVals.Add(dataRow.Kubatur);
                    yVals.Add(dataRow.Nettosumme);

                    if (maxXVal < dataRow.Kubatur)
                    {
                        maxXVal = dataRow.Kubatur;
                    }

                    NDataPoint dataPoint = new NDataPoint(dataRow.Kubatur, dataRow.Nettosumme);
                   
                    //Is the row selected?
                    if (dataRow.Auswahl)
                    {
                        selectedSeries.AddDataPoint(dataPoint);
                        //Store ID as Tag!
                        //DOES NOT WORK ANYMORE!!!!
                        //selectedSeries.Tags.Add(cntSelected, dataRow);
                        //selectedSeries.Tags[cntSelected] = dataRow;
                        cntSelected++;
                    }
                    else
                    {
                        unselectedSeries.AddDataPoint(dataPoint);
                        //Store ID as Tag!
                        //DOES NOT WORK ANYMORE!!!!
                        //unselectedSeries.Tags[cntUnSelected] = dataRow;
                        //unselectedSeries.Tags.Add(cntUnSelected, dataRow);
                        cntUnSelected++;
                    }
                }
            }
    chartControl.Refresh();
}






Similar Topics


Reading This Topic