How to Select a Specific Bar on a 2D Graph with the MouseLast reviewed: June 21, 1995Article ID: Q123840 |
The information in this article applies to:
- Professional Edition of Microsoft Visual Basic for Windows, version 3.0
SUMMARYThis article explains how to detect which one of the Slices or Bars on a 2D Bar Graph was selected with the mouse.
MORE INFORMATIONThe graph control does not have a built-in method that you can use to discover which bar or slice of a 2D Bar Graph your mouse pointer is currently over. However, the graph control's ColorData property does correspond to Visual Basic's QBColor() function. Therefore, if you display the Graph in a picture box by assigning the Graph's picture property to a picture box, you can use the picture box's Point(x,y) method to compare the color of the bar at the position of your mouse. You can use this method to differentiate up to 14 different points.
Step-by-Step Example
Notes- To change the Data in the graph control and refresh the picture use:
Graph1.DrawMode = 2 Picture1.Picture = Graph1.Picture- ColorData 0 is Black and 15 is White. By default the background is white and the lines are black, so don't use these colors. If you do, you might get invalid information.- This method will not work reliably if multiple datasets (NumSets > 1) or 3D versions of the bar graph are used. For multiple datasets, you may choose a specific color for each set. Then differentiate which set the user selects. A 3D bar uses black pixels for the shading effect, so it does not lend itself to this technique. |
Additional reference words: 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |