DOCUMENT:Q192902 21-SEP-1998 [vbwin] TITLE :HOWTO: Change Colors to Patterns with the MSChart Control PRODUCT :Microsoft Visual Basic for Windows PROD/VER:WINDOWS:5.0,6.0 OPER/SYS:WINDOWS KEYWORDS: ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0 on the following platforms: NT, Win95, Win98 --------------------------------------------------------------------- SUMMARY ======= By default, the MSChart control uses colors to differentiate between data sets. This works well on a color monitor or printer, but if a printout to a monochrome printer is created, the colors may be hard to distinguish. Using the code provided, you can programmatically change the MSChart control to use patterns instead of colors. MORE INFORMATION ================ Modifying some properties is all that needs to be done to get the MSChart control to use patterns. Step-by-Step Example -------------------- 1. Create a new Standard EXE project in Visual Basic. Form1 is created by default. 2. Choose Components from the Project menu to show the Components Dialog. 3. In Visual Basic 5.0, select "Microsoft Chart Control." In Visual Basic 6.0, select "Microsoft Chart Control 6.0 (OLEDB)." 4. Place an instance of the Chart control and a CommandButton on Form1. 5. Place the following code in the General Declaration Section of Form1: Private Sub Command1_Click() MSChart1.Plot.SeriesCollection(1).DataPoints(-1).Brush.Style _ = VtBrushStylePattern MSChart1.Plot.SeriesCollection(1).DataPoints(-1).Brush.Index _ = VtBrushPatternBoldDownDiagonal MSChart1.Plot.SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set _ 255, 255, 255 MSChart1.Plot.SeriesCollection(2).DataPoints(-1).Brush.Style _ = VtBrushStylePattern MSChart1.Plot.SeriesCollection(2).DataPoints(-1).Brush.Index _ = VtBrushPatternBoldHorizontal MSChart1.Plot.SeriesCollection(2).DataPoints(-1).Brush.FillColor.Set _ 255, 255, 255 MSChart1.Plot.SeriesCollection(3).DataPoints(-1).Brush.Style _ = VtBrushStylePattern MSChart1.Plot.SeriesCollection(3).DataPoints(-1).Brush.Index _ = VtBrushPatternBoldUpDiagonal MSChart1.Plot.SeriesCollection(3).DataPoints(-1).Brush.FillColor.Set _ 255, 255, 255 MSChart1.Plot.SeriesCollection(4).DataPoints(-1).Brush.Style _ = VtBrushStylePattern MSChart1.Plot.SeriesCollection(4).DataPoints(-1).Brush.Index _ = VtBrushPatternBoldVertical MSChart1.Plot.SeriesCollection(4).DataPoints(-1).Brush.FillColor.Set _ 255, 255, 255 End Sub 6. Run the project and click Command1 and note that the chart now uses monochrome patterns instead of colors. REFERENCES ========== For additional information, please see the following article in the Microsoft Knowledge Base: ARTICLE-ID: Q168749 TITLE : HOWTO: Print the Contents of the MS Chart Control Additional query words: kbDSupport kbDSD kbVBp kbVBp500 kbVBp600 kbCtrl ====================================================================== Version : WINDOWS:5.0,6.0 Platform : WINDOWS Issue type : kbhowto ============================================================================= 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. Copyright Microsoft Corporation 1998.