⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vel23.htm

📁 简单的说明如何使用VB,非常适合初学使用者,而且是用图表来解说的
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<UL><UL><P>SmallChange: 50</UL></UL><UL><UL><P>LargeChange: 100<BR></UL></UL><P>The shape control that contains the bar (named shpBar) has its Height property set to 2300, so the tallest that the bar could appear within the control was 2300 twips. Hence the use of 2300 for the Max property.<BR><P>The two Min properties of 50 keep both the circle and bar from shrinking entirely when the user minimizes either control.<BR><P>Lines 5 and 6 set the initial values for the circle's width and the bar's height to 1800, so both shapes are fairly large to begin with. Actually, the lines set the initial runtime values for both the scroll bars, which, in turn, generates the Change() event procedures that follow in the code.<BR><P>Line 12 ensures that the circle's width increases or decreases, depending on the value of the horizontal scroll bar's Value property. Line 18 ensures that the bar's height increases or decreases, depending on the value of the vertical scroll bar's Value property.<BR><BR><A NAME="E68E174"></A><H3 ALIGN=CENTER><CENTER><FONT SIZE=5 COLOR="#FF0000"><B>Prepare for the Grid Control</B></FONT></CENTER></H3><BR><P><FONT COLOR="#FF8000"><B><I>Concept: </I></B></FONT>Before you can use the grid control, you must add the grid control to your AUTOLOAD.MAK's Toolbox window.<BR><P>Lesson 2 removed the grid control from the Toolbox window. The grid control is a special custom control that wasn't part of Visual Basic's original toolbox. All custom controls reside in files on your disk with the filename extension of VBX. All applications that use the grid control must list the GRID.VBX file in the Project window.<BR><P>When you don't need the grid control, your applications will load more quickly and consume less disk space if you remove the GRID.VBX file from the application's Project window. Until now, the lessons in this book didn't need the grid control; therefore, Lesson 2 walked you through the steps to remove the grid control's customer GRID.VBX file from the AUTOLOAD.MAK's Project window.<BR><P>If you want to work with the grid control, you must add the GRID.VBX file to any application that requires the grid control. You can decide now whether you want to add GRID.VBX to AUTOLOAD.MAK so that all subsequent projects will contain the grid control or just add the GRID.VBX file to individual projects that use the grid control.<BR><P>The following steps explain how to add the grid control to AUTOLOAD.MAK. (If you want to remove the control after you complete this unit, you can do so by removing the control as explained in the second unit of Lesson 2.) To add the grid control to AUTOLOAD.MAK:<BR><OL><LI>Load the AUTOLOAD.MAK project.<BR><BR><LI>Select File Add File. Visual Basic displays the Add File dialog box.<BR><BR><LI>Select the file named GRID.VBX. The file should reside in your VBPRIMER directory.<BR><BR><LI>Press Enter or click the OK command button to close the dialog box. Visual Basic updates the Toolbox window so that the window contains the custom grid control as shown in Figure 23.3.<BR><BR><LI>Save the AUTOLOAD.MAK project.<BR><BR></OL><P><B> <A HREF="23vel02.gif">Figure 23.2. The location of the grid control on the toolbox.</A></B><BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><B>Note: </B>All new projects that you now create will contain the grid control in the Toolbox window and the GRID.VBX listing in the Project window.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P><FONT COLOR="#FF8000"><B><I>Review: </I></B></FONT>Before learning how to use the grid control, you must load the GRID.VBX custom control file into your project's Project window. By loading the file into AUTOLOAD.MAK's project, all subsequent projects will contain the grid control until you remove the custom control file.<BR><BR><A NAME="E68E175"></A><H3 ALIGN=CENTER><CENTER><FONT SIZE=5 COLOR="#FF0000"><B>Using the Grid Control</B></FONT></CENTER></H3><BR><P><FONT COLOR="#FF8000"><B><I>Concept: </I></B></FONT>The grid control produces a table of rows and columns in which you can display text, numeric values, and even graphics.<BR><P>When you must display several values at once, the grid control is one of the handiest controls to use. Although labels are great for messages and individual data items, and scrolling list boxes are fine for lists of values from which the user can select, the grid gives your application a two-dimensional table display of data.<BR><P>Suppose that you just started a lawn fertilization company, and you begin with an initial route of eight customers. Each customer requires five annual fertilizations. That's a total of 40 applications that you need to track for the upcoming year. Each yard size differs and each application requires different amounts and kinds of fertilization mixtures.<BR><P>Thinking about the eight customer's five applications, you realize that a table with eight rows and five columns would be the perfect place for placing pricing data in a computer application. After you build a Visual Basic application that contains the values, you could easily modify the table or store the values in a disk file. As you add additional customers, you could easily expand the size of the grid through the program's code.<BR><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><I>Definition: </I>A <I>cell</I> is one row and column intersection of a grid.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE><P>Before looking at an actual demonstration of a grid that tracks this lawn care business, take a few moments to study Figure 23.3. The figure shows the layout of cells on a grid that might appear on a form. The grid's size is determined by the grid's properties, which you can set or adjust using the mouse when you place the grid control on the form.<BR><P><B> <A HREF="23vel03.gif">Figure 23.3. The grid control produces a table of rows and columns.</A></B><BR><P><B>Tip: </B>The grid doesn't have be large enough to display all of its data. If the grid's size isn't large enough to hold all the grid's cells, Visual Basic adds scroll bars so that the user can scroll through the grid.<P>The figure's shaded row and column is known as a <I>fixed row</I> and <I>fixed column</I>. The grid's property value settings determine whether you want to set aside a fixed row or column. When you request one or more fixed rows or one or more fixed columns (or a combination of both), Visual Basic keeps those rows and columns from scrolling when the user scrolls through the grid's values.<BR><P>As the user views values inside the grid, the user can scroll through the grid, selecting (with the mouse or keyboard) one or more cells in the grid. Through programming, you can update or copy selected cell values to other grid controls, to variables, or to data files.<BR><P>Table 23.2 contains the property values available for a grid control. Although you've seen several of the properties for other controls, the grid does contain properties unique to the grid control that determine the dimensions of the grid as well as the number of fixed rows and columns.<BR><BR><P ALIGN=CENTER><CENTER><FONT COLOR="#000080"><B>Table 23.2. The grid control's properties.</B></FONT></CENTER><BR><TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 ><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080><I>Property</I></FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080><I>Description</I></FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>About...</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Clicking this About property opens a description dialog box that displays information about the grid control. Most custom controls come with these About dialog boxes that detail copyright information about the custom control. The About property is available only during program design time and does nothing at runtime.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>BackColor</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Specifies the grid control's background color, chosen as a hexadecimal color code or from the color palette. The BackColor describes the nonfixed row and column cell colors. All fixed row and column cells are gray.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>BorderStyle</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Specifies that a border appears around the grid if set to 1-Fixed Single (the default). No border appears if set to 0-None.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Cols</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds the number of columns in the grid.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>DragIcon</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Contains the icon that appears when the user drags the grid around on the form. (You'll only rarely allow the user to move a grid, so the Drag... property settings aren't usually relevant.)</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>DragMode</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds either 1 for manual mouse dragging requirements (the user can press and hold the mouse button while dragging the control) or 0 (the default) for automatic mouse dragging, meaning that the user can't drag the grid but that you, through code, can initiate the dragging if needed.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Enabled</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Determines whether the grid can respond to events. If set to True (the default), the grid can respond to events. Otherwise, Visual Basic halts event processing for that particular control.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>FillStyle</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>If set to 0-Single (the default), a value is to be assigned only to a single selected cell, and if 1-Repeat, a value is to be assigned to a range of selected cells.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>FixedCols</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds the number of fixed columns. The FixedCols value must be at least two fewer than the Cols value.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>FixedRows</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds the number of fixed rows. The FixedRows value must be at least two fewer than the Rows value.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontBold</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds True (the default) if the grid values are to display in boldfaced characters; False otherwise.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontItalic</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds True (the default) if the grid values are to display in italicized characters; False otherwise.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontName</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Contains the name of the grid values' font styles. Typically, you'll use the name of a Windows TrueType font.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontSize</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds the size, in points, of the font used for the grid values.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontStrikethru</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds True (the default) if the grid values are to display in strikethru letters (characters with dashes through them); False otherwise.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>FontUnderline</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds True (the default) if the grid values are to display in underlined letters; False otherwise.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>ForeColor</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Specifies the color of the characters in the grid values.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>GridLines</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds True (the default) if the grid is to control separating row and column lines; False otherwise.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Height</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds the height, in twips, of the grid.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>HelpContextID</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>If you add advanced, context-sensitive help to your application, the HelpContextID provides the identifying number for the help text.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Highlight</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds True (the default) or False to determine whether selected cell or cells are to appear highlighted.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Index</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>If the grid is part of a control array, the Index property provides the numeric subscript for each particular grid control.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Left</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Contains the number of twips from the left edge of the Form window to the left edge of the grid.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Name</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Contains the name of the control. By default, Visual Basic generates the names Grid1, Grid2, and so on as you add subsequent grids to the form.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Rows</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds the number of rows in the grid.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>ScrollBars</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds 0-None, 1-Horizontal, 2-Vertical, or 3-Both (the default) to describe the scroll bars that appear in the grid if the grid requires more row and column space than the grid size allows.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>TabIndex</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Determines that the focus tab order begins at 0 and increments every time you add a new control. You can change the focus order by changing the controls' TabIndex to other values. No two controls on the same form can have the same TabIndex value.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>TabStop</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>If True, determines whether the user can press Tab to move the focus to this grid. If False, the grid can't receive the focus.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Tag</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Unused by Visual Basic. This is for the programmer's use for an identifying comment applied to the grid.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Top</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds the number of twips from the top edge of a grid to the top of the form.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Visible</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds True or False, indicating whether the user can see (and, therefore, use) the grid.</FONT><TR><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Width</FONT><TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>Holds the number of twips wide that the grid consumes.</FONT></TABLE><BLOCKQUOTE><BLOCKQUOTE><HR ALIGN=CENTER><BR><NOTE><FONT COLOR="#FF8000"><B><I>Warning: </I></B></FONT>The grid control enables your user to view and scroll through values but doesn't allow the user to enter new values into the grid. Your program can update the grid, but the user can't.</NOTE><BR><HR ALIGN=CENTER></BLOCKQUOTE></BLOCKQUOTE>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -