I have a databound chart in a winforms application, written in vb.net. I have setup the 3 points in my data and set their colours, but when the chart is filled at runtime, it ignores the pre-defined points and chooses random colours.
In order to get around this, I have added 3 lines of code to manually set the colours of the points after the data is generated. I have tried putting this in the Load event and the Shown event, but each time it fails due to the reference being outside of the index.
I think this is happening because the form isn't shown on screen yet, and so the points don't actually exist just yet.
I tried putting the code in a button and clicking it once the chart had loaded, and this changed the colours successfully.
Code in Load
event:
Me.Prod_ChecklistGraphTableAdapter.Fill(Me.ProdGraph.prod_ChecklistGraph)
Code in Shown
or below the above line in Load
event:
chtActiveStatus.Series(0).Points(0).Color = Color.FromArgb(180, 204, 112)
chtActiveStatus.Series(0).Points(1).Color = Color.FromArgb(255, 200, 61)
chtActiveStatus.Series(0).Points(2).Color = Color.FromArgb(255, 61, 61)
My question is, how can I make this code change the colours before the chart is shown to the user and preventing it from flickering from one colour to the right colour? Or alternatively, how can I set the chart properties so that it doesn't ignore the pre-definded Points and colours I have set up?