I am totally missing how to add a legend to a chart programmatically (versus dragging a chart object into designer). I thought this was done similar to creating a series or chart area. For example,
Dim Legend1 As New Legend()
Chart2.Legends.Add(Legend1)
This leads to the error: The chart element with the name Legend1 could not be found in the Legend collection.
If I use the example code provided from Samples Environment for Microsoft Chart Controls - Release: Samples for Chart Control - .NET Framework 4
and simply reference some "Default" as in (and assume the Legend already exists)
Chart1.Legends("Default").LegendStyle = LegendStyle.Column
I get a complaint about default.
Can someone help me instantiate a legend for a graph. Thanks
Dim Legend1 As New Legend()
Chart2.Legends.Add(Legend1)
This leads to the error: The chart element with the name Legend1 could not be found in the Legend collection.
If I use the example code provided from Samples Environment for Microsoft Chart Controls - Release: Samples for Chart Control - .NET Framework 4
and simply reference some "Default" as in (and assume the Legend already exists)
Chart1.Legends("Default").LegendStyle = LegendStyle.Column
I get a complaint about default.
Can someone help me instantiate a legend for a graph. Thanks