How to Clear the Legend Information from a Graph Control

Last reviewed: June 21, 1995
Article ID: Q113997
The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows, version 3.0

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

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. 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

  3. 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
    
    

  4. 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.

REFERENCES

This article is based on the following articles in the Microsoft Knowledge Base:

ARTICLE-ID: Q81999

TITLE     : BUG: Graph: AutoInc Increments ThisPoint Instead of ThisSet

ARTICLE-ID: Q82155
TITLE     : VB Graph Control: ThisPoint, ThisSet Reset to 1 at Run Time

ARTICLE-ID: Q96450
TITLE     : Set DrawMode to 2 Or 3 to Update Changes to Graph at Run Time


Additional reference words: 3.00
KBCategory: kbprg kbcode
KBSubcategory: PrgCtrlsCus


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.