.net: keep series colors when adding and removing other series?

When you add and remove a series from a .net network control (line chart), how can I save existing series colors?

Currently, when I add several rows to a chart, they all get the colors assigned automatically from the chart palette. But if I delete the first series, the colors of all subsequent series will get reset according to the order in the chart palette. Is there any way to stop this?

Thanks in advance.

+3
source share
2 answers

Why don't you just set the colors of the chart directly and not use the palette?

Chart.Palette = ChartColorPalette.None;
Chart.Series[0].Color = Color.Green;

.. .. , , , c'est la vie.

+5

ApplyPaletteColors, .

, :

chart1.ApplyPaletteColors();
series1.Color = series1.Color;
series2.Color = series2.Color;
..
-1

Source: https://habr.com/ru/post/1775613/