Visual Basic 6 Black Book:The Chart And Grid Controls
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Chapter 12The Chart And Grid Controls
If you need an immediate solution to:
Adding A Chart Control To A Program
Adding Data To A Chart Control
Working With A Multiple Data Series
Setting Chart And Axis Titles And Chart Colors
Creating Pie Charts
Creating 2D And 3D Line Charts
Creating 2D And 3D Area Charts
Creating 2D And 3D Bar Charts
Creating 2D And 3D Step Charts
Creating 2D And 3D Combination Charts
Adding A Flex Grid Control To A Program
Working With Data In A Flex Grid Control
Typing Data Into A Flex Grid
Setting Flex Grid Grid Lines And Border Styles
Labeling Rows And Columns In A Flex Grid
Formatting Flex Grid Cells
Sorting A Flex Grid Control
Dragging Columns In A Flex Grid Control
Connecting A Flex Grid To A Database
In Depth
In this chapter, were going to work with two types of Visual Basic controls: chart and grid controls. You use these controls to display datafor example, a chart of a data set can make it come alive in a unique way. Like most Visual Basic controls, both of these control types can be filled with data in two ways: under program control or from a database. In this chapter, well get familiar with charts and grids and placing data in them ourselves; when we discuss the Visual Basics data-bound controls later in this book, well see how to make the connection to databases.
The Chart Control
The Visual Basic chart control takes a little getting used toand its changed significantly over timebut when you get the hang of it, you can create dramatic effects. For making your data visible, theres little better than an effective graph. Here are the types of charts you can create using the Visual Basic chart control:
2D or 3D bar chart
2D or 3D line chart
2D or 3D area chart
2D or 3D step chart
2D or 3D combination chart
2D pie chart
2D XY chart
As well see, there are several ways of working with the data in a chart control; that data is stored in a data grid, and were responsible for filling that grid. To create a simple graph, such as a line chart showing wheat production over time, you fill the data grid with a one-dimensional array. If you want to display a graph of a series of data sets in the same chart, such as a line chart with three lines showing wheat, soybean, and rye production over time, you use a two-dimensional array (with three columns in this case). Well see how this works in the Immediate Solutions.
To add a chart control to your program, open the Components dialog box by selecting Project[vbar]Components, click the Controls tab, select the Microsoft Chart Control entry, and click on OK to close the Components dialog box. The Chart Control tool appears as the eleventh tool down on the right in Figure 12.1.
Figure 12.1 The Chart Control tool.
The chart control takes care of many programming concerns automaticallysuch as scaling the axes or setting colorsalthough you can override those settings if you wish.
Grid Controls
Grid controls display data in a table-like form, with rows and columns of cells. In fact, you can use grids to do just that: display tables of data. You can also use them to display spreadsheets.
Visual Basic has a number of grid controls: the data grid control, the flex grid control, and the hierarchical flex grid control. Well take a look at the flex grid control here and save the data grid control for our discussion of data-bound controls (in fact, flex grids can connect to databases just as data grid controls can, but they present the databases data in read-only format).
Like charts, grids give you a way of displaying data. Whereas charts present data in graphical format, grids appear like spreadsheets (and, in fact, if you want to create a spreadsheet in Visual Basic, you use a grid). A grid presents the user with a two-dimensional array of individual cells. You can make the cells in the grid active just as youd expect in a spreadsheet; for example, you can keep a running sum at the bottom of columns of data.
One thing that takes many Visual Basic programmers by surprise is that theres no automatic way for users to enter data in a grid control (that is, it doesnt function as a grid of text boxes). When you display a grid, it seems that users should be able to just type the data they want into the grid, but thats not the way it works.
Grid controls can hold data in each cell when you put it there, but the user cant simply enter that datayou have to add the code to do that. Well see how to fix this with a moveable text box in this chapterwhen the user types into a cell, well move the text box to that cell and make it appear that the user is typing directly into the cell.
The flex grid control is often used to display database data in read-only format. It also features the ability to rearrange its columns under user control, as well see, as well as the ability to display images in each cell instead of just text. Each cell supports word wrap and formatting.
To add a flex grid control to your program, open the Components dialog box by selecting Project[vbar]Components, click the Controls tab, select the Microsoft FlexGrid Control entry, then click on OK to close the Components dialog box. The Flex Grid Control tool is the twelfth tool down on the left in Figure 12.2.
Figure 12.2 The Flex Grid Control tool.
Thats it for our overview of charts and gridsits time to turn to the Immediate Solutions.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
371 37413 (374)373 374374 Premia pieniężna w księgach rachunkowych01 (371)371 Reklamacja zużytych materiałów budowlanych uznana przez producenta374 378371 373371 37310 (371)369 371więcej podobnych podstron