Microsoft KB Archive/113997

= How to Clear the Legend Information from a Graph Control =

Article ID: 113997

Article Last Modified on 1/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q113997



SUMMARY
The Graph Control is one of the most versatile of the custom controls included with Visual Basic Professional, but it is also complex and can be difficult to master. It is easy to add legends using the LegendText property, but removing legends is not at all intuitive. It is necessary to set the DataReset property to 5 to clear the legend information.



MORE INFORMATION
The following example demonstrates how switching a graph between different numbers of sets produces an anomalous result when the DataReset property is not used.

Steps to Reproduce Behavior
 Start a new project in Visual Basic. Form1 is created by default. Add a graph control (Graph1) and 2 command buttons (Command1 and Command2) to Form1. Be sure to make the Graph control large enough to accommodate the legend  Add the following code to the Command1_Click and Command2_Click event procedures of Form1: Sub Command1_Click ' Remove the apostrophe from following line to remove the legend: ' graph1.DataReset = 5 graph1.ThisPoint = 1 graph1.LegendText = "1992" graph1.ThisPoint = 2 graph1.LegendText = "" graph1.NumSets = 1 graph1.DrawMode = 2 End Sub

Sub Command2_Click graph1.LegendText = "1992" graph1.NumSets = 2 graph1.ThisPoint = 2 graph1.LegendText = "1993" graph1.DrawMode = 2 End Sub  Run the application by choosing Start from the Run menu or by pressing the F5 key.

Click the Command1 and Command2 buttons back and forth several times and observe the result. You will see that the legend from the previous data was not completely deleted. Now remove the apostrophe from the second line of code in the Command1_Click event procedure and repeat the process. You will see that it is now deleted.

