C ++ Builder First Learning and Answer (4)

zhaozj2021-02-16  46

4. List class components

31) Q: When I need to use multiple options, use radio buttons or checkboxes to choose not very appropriate, because placing a lot of buttons on the form is not conducive to the beauty of the layout, which will consume a lot of What is the solution for system resources, C Builder?

A: You can use the list of the most common list of lists of the two categories of list boxes (Listbox, Checklistbox) or Combobox.

32) Q: What is the main attributes in the list box?

A: List component Listbox can only be selected by default, and multiple selections can be performed when the property multisable is TRUE. At this time, you only click the desired option, then these options will be selected.

Items Properties: All options in the list box are accessed through this property. As soon as you set it, you can edit it when you click "..." on the right side of items.

When the property extendedselect is also equal to TRUE, there are two ways to make multiple options. One is to click the option to press the Ctrl key at the same time, so that all options between the two options can be selected. Its default value is false.

The sorted property determines whether the content displayed in the list box is arranged in alphabetical order. The default is false.

When multiple options are not allowed, we can return to the selected options through the property ItemIndex. However, if you have opened a number of options, the property ItemInDex only returns the last selected option serial number (some books also say that the option is available in the options in the option, but I think this statement is not easy to let beginners understand ).

When the SELCOUNT property is TRUE when the multiselected property is true, the number of selected items in the list box is pointed out. When the multislected property is false, its value is -1.

The selected property indicates whether a project in the list box is selected.

TcheckListbox is inherited from TcustomListBox. TListbox is also inherited directly from TcustomListBox, so these two components are brothers, and their properties and use are very similar. Let's take a look at it different:

The allowgrayed property and multiple selection buttons are the same. When the property value is TRUE, the options in the list box have three status: selected, unchecked, and select, but when the attribute value is false, the list box has only two states. The default is false.

Checked its statement as: _property bool checkage [int index]; this property is used to return or set whether the specified option in the list box is selected. The parameter index represents the serial number of the specified option.

32) Q: So, the combo box and the list box have something similar to a different place?

A: First, from the look, the list box occupies a relatively large space, and the combo box only needs a line of space. From another aspect, the combo box also has an edit box, and the user can enter text directly in the edit box. The combo box is only displayed in general, when the user clicks the pull arrow on the right side of the combo box, A drop-down list containing all options will be displayed.

The largest combination box and the list box is that the combo box cannot do multiple options.

The combo box has a certain similarity to the list box, that is, they can contain a lot of options. But the combo box still has a lot of unique properties.

33) Q: What are the common attributes and events in the combination box?

A: The attribute style determines the style of the combo box, and C Builder defines five different styles to the combo box.

CSDropDown: At this time, it consists of a standard combo box, consists of an editing box and drop-down list.

CSDropDownList: Similar to the standard combo box, but cannot enter text in the edit box. CSSIMPLE: There is no combination box of the drop-down list, just an edit box, that is, only entered can't choose.

CSOWNERDRAWFIXED and CSOWNERDRAWVARIABLE These two styles of styles are often used as an image as an item, of course you enter a string or. The height of each item in the previous style combination box is fixed, while the height of a styles can vary, that is, the height of each item can be different, in addition, in these two styles, the edit box is not Input.

The Text property is used to set or return the text content displayed in the combo box.

The ONCHANGE event will be triggered when the content in the edit box changes. So in the combination box we use it.

Note the differences and contacts of the two groups of statements below:

//………………First group

Void _fastcall TFORM1 :: ComboBox1change (TOBJECT * SENDER)

{

IF (ComboBoX1-> Text! = ")

Edit1-> font-> size = strt (ComboBox1-> text);

}

The above code can also be written as the following, their effect is the same:

Void _fastcall TFORM1 :: ComboBox1change (TOBJECT * SENDER)

{

IF (! ComboBoX1-> text.isempty ())

Edit1-> font-> size = comboBOX1-> text.Toint ();

}

//………………Second Group

Void_fastcall tform1 :: ComboBox2change (Tobject * Sender)

{

Edit1-> font-> name = comboBox2-> text;

}

You can also use the following code, they are here equivalent:

Void_fastcall tform1 :: ComboBox2change (Tobject * Sender)

{

Edit1-> font-> name = comboBox2-> items-> string [comboBox2-> itemindex];

}

I want to pass comparison, you will understand the differences and contacts of these statements, when can I use what kind of statement, delicate taste, you will understand J

34) Q: In front of you mentioned the panel assembly, what type of component is it?

A: It is a container assembly that is a component that can contain other components. The most typical container component is a form. Other commonly used container components have panels (PANEL), groupbox.

The panel assembly can accommodate other components. Any components placed on the panel become subcomponents of panels, when you delete panel components, other components placed on the panel are also deleted at the same time, which is the common feature of the container components.

There is no special attribute of panel components, only Bevelinner (panel internal bevel), Bevelouter, BevelWidth, BordersTyle and Borderwidth have some characteristics. Any combination of these attributes can generate a border of various effects. You can set the value of these properties, you can get different panel effects.

The property value of the Bevelinner, Bevelouter is the same: Bvnone indicates no inclined; bvLowRed is expressed as a slope of the settlement;

BVRAISED is expressed as a rising slope.

In the GroupBox property, you can set the CAPTION, it is the name of the title, indicating this combination box category, function, option, etc. GROUPBOX1 is the default name.

5. Special input control class components

35) Q: What input control class components are C Builder?

A: The C Builder input control class component mainly includes scroll bar, trackbar, process bar, and add-oriented component Updown, which can achieve selection of value-wide values.

36) Q: Where is the scroll bar mainly, what is it common to the usual properties?

A: The scroll bar is a common component, which often appears in the list box, MEMO and other components. At this time, it is existing as part of these components. In fact, the scroll bar can also be used alone. When used alone, the scroll bar is generally used to control the continuous numerical input. The scroll bar can be entered using the scroll bar.

Rolling bars have such common properties

1. Position: This property is used to set or return the position of the slider in the current flow bars. Attributes Max, Min, used to set the maximum or minimum position of the scroll bar to scroll. When the position is equal to MAX, the scrolling block is at the rightmost end of the scroll bar; when the position is equal to MIN, the rolling block is located at the leftmost end of the scroll bar. When the position is equal to a value between MAX and MIN, the scrolling block is located in a certain location in the middle of the scroll bar.

2. Property Kind. The property Kind has two possible values: SBhorizontal and SBvertical, indicating the horizontal scroll bar and the vertical scroll bar, respectively.

3. The attribute SmallChange determines the distance from the scroll block when the user clicks the arrow button at both ends of the roll.

4. The attribute largechange determines the distance from the scroll block when the user clicks on the blank of the scroll block or pressing the PGUP and PGDN keys. The value of the property LARGECHANGE and SmallChange ranges from 1 to 32767.

37) Q: What commonly used events can the scroll bar can respond?

A: The common event of the scroll bar is onchange, as long as the value of the property Position changes, this event will be generated. In general, this property of understanding the scroll bar is OK.

However, sometimes it is necessary to understand which location of the user clicks on the scroll bar. At this time, it is necessary to respond to the onscroll event, which is: _property tscrollevent onscroll; Tscrollevent's declaration is: typedef void fast (Closuer Tscrollevent) (System Tscrollevent) (SYSTEM :: Tobject Sender, TscrollCode Scrollcode, Int & Scrollpos; OnScroll Event Handle has three parameters:

The parameter sender pointed out which object sent this message. The parameter scrollpos pointed out that the position of the scroll block, the parameter scrollcode returns the state of the scroll bar, which is represented by such a parameter value.

SclineUp indicates that the user clicks the arrow button (horizontal scroll bar) or the upper end arrow button (vertical scroll bar) on the left end of the scroll bar. SClineDown indicates that the user clicks the (horizontal scroll bar) or the lower end of the rolling bar right (vertical scroll bar). SCPageUp indicates that the user clicks the area of ​​the rolling block left (horizontal scroll bar) or the upper (vertical scroll bar). SCPAGEDOWN indicates the user in the right of the rolling block right (horizontal scroll bar) or the lower (vertical scroll bar). SCPosition said that the user moved the scroll bar but has been released. Sctrack represents the user who is moving the scroll block. SCTOP indicates that the user moves the scroll block to the left end (horizontal scroll bar) or the top (vertical scroll bar) of the scroll bar. SCBOTTOM represents the user moves the scroll block to the right end (horizontal scroll bar) or the lower end (vertical scroll bar). Scendscroll indicates that the user ends the operation of the mobile scroll block, releases the mouse or keyboard button. (to be continued)

转载请注明原文地址:https://www.9cbs.com/read-26015.html

New Post(0)