ch07.htm
来自「delphi自学的好教材!特别适合刚刚起步学习delphi的人员!同样对使用者具」· HTM 代码 · 共 1,443 行 · 第 1/5 页
HTM
1,443 行
<TD ALIGN="LEFT">When set to True, text in the edit control will automatically be selected when the user tabs to the control. Default: True</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">AutoSize</TD> <TD ALIGN="LEFT">Edit, MaskEdit</TD> <TD ALIGN="LEFT">When set to True, the edit control will automatically resize itself when the font of the edit control changes. Otherwise, the edit control does not change size when the font changes. Default: True</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">CharCase</TD> <TD ALIGN="LEFT">Edit, MaskEdit</TD> <TD ALIGN="LEFT">Determines whether the edit control displays uppercase (ecUpperCase), lowercase (ecLowerCase), or mixed text (ecNormal). Default: ecNormal.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">HideScrollBars</TD> <TD ALIGN="LEFT">RichEdit</TD> <TD ALIGN="LEFT">When set to True, the scrollbars will be shown when needed but hidden otherwise. When set to False, the scrollbars are shown as determined by the value of the ScrollBars property.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">HideSelection</TD> <TD ALIGN="LEFT">Edit, Memo, RichEdit</TD> <TD ALIGN="LEFT">When set to True, any text selected will not show as selected when the user tabs to another control. Default: False</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Lines</TD> <TD ALIGN="LEFT">Memo, RichEdit</TD> <TD ALIGN="LEFT">The text contained in the component. Lines is an instance of the TStrings class.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">MaxLength</TD> <TD ALIGN="LEFT">All</TD> <TD ALIGN="LEFT">Specifies the maximum number of characters that the component will hold. When set to 0, the amount of text that can be input is unlimited (limited only by system considerations). When set to any non-zero value, limits the number of characters to that value. Default: 0</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">OEMConvert</TD> <TD ALIGN="LEFT">Edit, Memo</TD> <TD ALIGN="LEFT">Set this property to True when the text input will consist of filenames. Default: False</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">PasswordChar</TD> <TD ALIGN="LEFT">Edit, MaskEdit</TD> <TD ALIGN="LEFT">When this property is set to a value other than ASCII #0, any text entered will be echoed with the character provided. The actual text in the edit control is unaffected. Most password edits use the asterisk (*) as the password character. Default: #0</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">PlainText</TD> <TD ALIGN="LEFT">RichEdit</TD> <TD ALIGN="LEFT">When set to True, RTF (rich text format) files will be shown as plain text without character and paragraph formatting. When set to False, RTF files are displayed with full formatting. Default: False</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">ReadOnly</TD> <TD ALIGN="LEFT">All</TD> <TD ALIGN="LEFT">When set to True, the component will display its text, but new text cannot be entered. The user can, however, highlight text and copy it to the Clipboard. Default: False</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">ScrollBars</TD> <TD ALIGN="LEFT">Memo, RichEdit</TD> <TD ALIGN="LEFT">Determines which scrollbars to display. Choices are ssNone, ssBoth, ssHorizontal, and ssVertical. Default: ssNone</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Text</TD> <TD ALIGN="LEFT">Edit, MaskEdit</TD> <TD ALIGN="LEFT">Contains the text in the component.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">WantReturns</TD> <TD ALIGN="LEFT">Memo, RichEdit</TD> <TD ALIGN="LEFT">When set to True, the component keeps the return character and a new line is inserted in the edit control when the user presses Enter. When set to False, return characters go to the form and are not placed in the edit control. If you have a form with a default button and WantReturns set to False, pressing Enter will cause the form to close. Default: True</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">WantTabs</TD> <TD ALIGN="LEFT">Memo, RichEdit</TD> <TD ALIGN="LEFT">When set to True, a tab character is placed in the edit control when the user presses the Tab key. When set to False, tab characters go to the form, which would enable tabbing out of the edit control. Default: False</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">WordWrap</TD> <TD ALIGN="LEFT">Memo, RichEdit</TD> <TD ALIGN="LEFT">When set to True, text entered will wrap to a new line when the right edge of the edit control is reached. When set to False, the edit control automatically scrolls as new text is entered. Default: True</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Modified</TD> <TD ALIGN="LEFT">All</TD> <TD ALIGN="LEFT">Indicates whether the contents of the edit control have changed since the last time the Modified property was set. After saving the contents of a Memo or RichEdit component to a file, you should set Modified to False.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">SelLength</TD> <TD ALIGN="LEFT">All</TD> <TD ALIGN="LEFT">Contains the length of the text currently selected in the edit control.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">SelStart</TD> <TD ALIGN="LEFT">All</TD> <TD ALIGN="LEFT">Contains the starting point of the selected text in the edit control. The first character in the edit control is 0.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">SelText</TD> <TD ALIGN="LEFT">All</TD> <TD ALIGN="LEFT">Contains the currently selected text in an edit control.</TD> </TR></TABLE></P><P>Edit controls have many common methods; they are too numerous to list here. TheCutToClipboard, CopyToClipboard, PasteFromClipboard, and Clear methods deal withClipboard operations and text manipulation. The GetSelTextBuff and GetTextBuff methodsretrieve the selected text in the component and the entire text in the component,respectively. See the Delphi online help topics TEdit, TMaskEdit, TMemo, and TRichEditfor a complete list of methods associated with each edit component.</P><P>The edit component events that you are most likely to be interested in are dependenton the type of edit control you are using. In general, though, the OnEnter, OnExit,OnChange, OnKeyDown (or OnKeyPress), and OnKeyUp events will be the most widely used.</P><P><H3><A NAME="Heading19"></A>The ListBox and ComboBox Components</H3><P>The ListBox and ComboBox components are also widely used. The ListBox componentrepresents a standard Windows list box, which simply presents a list of choices thatthe user can choose from. If the list box contains more items than can be shown atone time, scrollbars provide access to the rest of the items in the list box.</P><P><strong>New Term:</strong> Some list boxes are <I>owner-drawn</I> list boxes. In an owner-drawnlist box, the programmer takes the responsibility for drawing the items in the listbox.</P><P>You can do owner-drawn list boxes if needed. Owner-drawn list boxes are fairlycommon, although you might not realize it. On Day 4 I talked about customizing theDelphi toolbar. As part of that discussion, you looked at the Delphi Toolbar Editordialog box. The Toolbar Editor dialog box contains two list boxes (see Figure 7.4).</P><P><A HREF="javascript:popUp('28670704.gif')"><B>FIGURE 7.4.</B></A><B> </B><I>TheToolbar Editor's Commands list box is owner-drawn.</I></P><P>The list box on the left is a regular list box; it lists the possible button groupsyou can choose from. The list box on the right is an owner-drawn list box. It showsthe actual button as it will appear on the toolbar, as well as a textual descriptionof what function the button performs.</P><P>Combo boxes are specialized list boxes. Actually, a combo box is a combinationof a list box and an edit control. The user can choose from the list or type in avalue in the edit portion. When the user chooses an item from the list, that itemis placed in the edit control. There are three different types of combo box. Thecombo box type is determined by the Style property. Table 7.5 lists the types ofcombo boxes and a description of each.</P><P><H4>TABLE 7.5. TYPES OF COMBO BOXES.</H4><P><TABLE BORDER="1"> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT"><I>Item</I></TD> <TD ALIGN="LEFT"><I>Description</I></TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Simple</TD> <TD ALIGN="LEFT">The simple style of the combo box is nothing more than an edit control placed on top of a list box. The user can choose from the list or type text in the edit portion.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Drop-down</TD> <TD ALIGN="LEFT">Similar to the simple style, except the list box portion is not initially displayed. A drop-down button is provided so that the user can view the list and choose an item. The user can also type text in the edit portion.</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Drop-down list</TD> <TD ALIGN="LEFT">This is the most restrictive type of combo box. As with the drop-down style, the list is not initially exposed. The user can click the drop-down button to expose the list and choose an item from the list, but cannot enter text in the edit portion. Use this style when you want the user to select only from a predetermined set of choices.</TD> </TR></TABLE></P><P>The book's code contains a program called ComboTst that illustrates the differenttypes of combo boxes. Figure 7.5 shows the test program running. Run the programand try out the combo boxes to get a feel for how each works.</P><P><A HREF="javascript:popUp('07fig05a.gif')"><B>FIGURE 7.5.</B></A><B> </B><I>TheComboTst program.</I></P><P>Table 7.6 lists the properties common to list boxes and combo boxes.</P><P><H4>TABLE 7.6. PROPERTIES FOR EDIT CONTROLS.</H4><P><TABLE BORDER="1"> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT"><I>Property</I></TD> <TD ALIGN="LEFT"><I>Applies To</I></TD> <TD ALIGN="LEFT"><I>Description</I></TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT" COLSPAN="3"><B>Properties</B></TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Columns</TD> <TD ALIGN="LEFT">ListBox</TD> <TD ALIGN="LEFT">Contains the number of columns in the list box. You can create multiple columns by making this property greater than 1. Default: 0</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">ExtendedSelection</TD> <TD ALIGN="LEFT">ListBox</TD> <TD ALIGN="LEFT">Determines whether extended selection is allowed. <I>Extended selection</I> enables the user to select items using Shift+click and Ctrl+click. Has no effect if MultiSelect is set to False. Default: True</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">IntegralHeight</TD> <TD ALIGN="LEFT">ListBox</TD> <TD ALIGN="LEFT">When True, the list box height will be resized to be sure that no partial lines are displayed. When False, the list box might show partial lines. Default: False</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">ItemHeight</TD> <TD ALIGN="LEFT">Both</TD> <TD ALIGN="LEFT">For use with owner-drawn list boxes and combo boxes. Sets the height of the items in the control. Default: 13</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Items</TD> <TD ALIGN="LEFT">Both</TD> <TD ALIGN="LEFT">A TStrings instance that contains the list of items in the list box. (See the section on TStrings earlier in this chapter for a description of available properties and methods.)</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">MaxLength</TD> <TD ALIGN="LEFT">ComboBox</TD> <TD ALIGN="LEFT">The maximum number of characters the user can type in the edit portion of the combo box. Same as MaxLength in edit controls. Default: 0 (no limit)</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">MultiSelect</TD> <TD ALIGN="LEFT">ListBox</TD> <TD ALIGN="LEFT">When True, the list box enables multiple items to be selected. Default: False</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Sorted</TD> <TD ALIGN="LEFT">Both</TD> <TD ALIGN="LEFT">When set to True, the list box items are sorted in ascending order. When set to False, the items are not sorted. Default: False</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Style</TD> <TD ALIGN="LEFT">ComboBox</TD> <TD ALIGN="LEFT">The style of the combo box. Choices are csSimple, csDropDown, csDropDownList, lbOwnderDrawFixed, and csOwnerDrawVariable. (See Table 7.5 for a description of the three basic styles.) Default: csDropDown</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT"></TD> <TD ALIGN="LEFT">ListBox</TD> <TD ALIGN="LEFT">Style choices for list boxes are lbStandard, lbOwnderDrawFixed, and csOwnerDrawVariable. Default: lbStandard</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">TabWidth</TD> <TD ALIGN="LEFT">ListBox</TD> <TD ALIGN="LEFT">List boxes can use tabs. This property sets the tab width in pixels. Default: 0</TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Text</TD> <TD ALIGN="LEFT">ComboBox</TD> <TD ALIGN="LEFT">Contains the text in the edit portion of the combo box.</TD> </TR> <TR ALIGN="CENTER" VALIGN="TOP"> <TD ALIGN="CENTER" COLSPAN="3"> <P ALIGN="CENTER"><B>Runtime Properties</B> </TD> </TR> <TR ALIGN="CENTER" VALIGN="TOP">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?