Control Element Forms in Detail

From Wiki
Jump to navigationJump to search





The control elements available in forms are similar to those of dialogs. The selection ranges from simple text fields through list and combo boxes to various buttons.

Below, you will find a list of the most important properties for control element forms. All properties form part of the associated model objects.

In addition to the standard control elements, a table control element is also available for forms, which enables the complete incorporation of database tables. This is described in the Database Forms chapter.

Buttons

The model object of a form button provides the following properties:

BackgroundColor (long)
background color
DefaultButton (Boolean)
the button serves as a default value. In this case, it also responds to the entry button if it has no focus
Enabled (Boolean)
the control element can be activated
Tabstop (Boolean)
the control element can be reached through the tabulator button
TabIndex (Long)
position of control element in activation sequence
FontName (String)
name of font type
FontHeight (Single)
height of character in points (pt)
Tag (String)
string containing additional information, which can be saved in the button for program-controlled access
TargetURL (String)
target URL for buttons of the URL type
TargetFrame (String)
name of window (or frame) in which TargetURL is to be opened when activating the button (for buttons of the URL type)
Label (String)
button label
TextColor (Long)
text color of control element
HelpText (String)
automatically displayed help text which is displayed if the mouse cursor is above the control element
HelpURL (String)
URL of online help for the corresponding control element
ButtonType (Enum)
action that is linked with the button (default value from com.sun.star.form.FormButtonType)
State (Short)
in toggle button, 1 = pushed, 0 = normal

Through the ButtonType property, you have the opportunity to define an action that is automatically performed when the button is pressed. The associated com.sun.star.form.FormButtonType group of constants provides the following values:

PUSH
standard button
SUBMIT
end of form entry (particularly relevant for HTML forms)
RESET
resets all values within the form to their original values
URL
call of the URL defined in TargetURL (is opened within the window which was specified through TargetFrame)

The OK and Cancel button types provided in dialogs are not supported in forms.

Option Buttons

The following properties of an option button are available through its model object:

Enabled (Boolean)
the control element can be activated
Tabstop (Boolean)
the control element can be reached through the tab key
TabIndex (Long)
position of control element in the activation sequence
FontName (String)
name of font type
FontHeight (Single)
height of character in points (pt)
Tag (String)
string containing additional information, which can be saved in the button for program-controlled access
Label (String)
inscription of button
Printable (Boolean)
the control element can be printed
State (Short)
if 1, the option is activated, otherwise it is deactivated
RefValue (String)
string for saving additional information (for example, for administering data record IDs)
TextColor (Long)
text color of control element
HelpText (String)
automatically displayed help text, which is displayed if the mouse cursor is above the control element
HelpURL (String)
URL of online help for the corresponding control element

The mechanism for grouping option buttons distinguishes between the control elements for dialogs and forms. Whereas control elements appearing one after another in dialogs are automatically combined to form a group, grouping in forms is performed on the basis of names. To do this, all option buttons of a group must contain the same name. OpenOffice.org combines the grouped control elements into an array so that the individual buttons of a OpenOffice.org Basic program can be reached in the same way.

The following example shows how the models of the control elements of a group can be iterated, exemplary displaying the states of all control elements in a given group:

Function test
  Dim oGroup as object
  Dim Doc As Object
  Dim Forms As Object
  Dim Form As Object
  Dim Ctl As Object
  Dim I as Integer
 
  Doc = ThisComponent
  Forms = Doc.Drawpage.Forms
 
  Form = Forms.GetbyIndex(0)

  oForm.getGroupByName("MyOptions", oGroup)
  msg = ""
  for i = LBound(oGroup) to UBound(oGroup)
    oCtl = oGroup(i)
    msg = msg + oCtl.Name + ": " + (str(oCtl.State)) + chr(10)
  next i
  MsgBox msg 

end Function

The code corresponds to the previous example for determining a simple control element model. It accesses the array of models using the GetGroupByName method (rather than the GetByName method to determine simple models).

Checkboxes

The model object of a checkbox form provides the following properties:

Enabled (Boolean)
the control element can be activated
Tabstop (Boolean)
the control element can be reached through the tab key
TabIndex (Long)
position of control element in the activation sequence
FontName (String)
name of font type
FontHeight (Single)
height of character in points (pt)
Tag (String)
string containing additional information, which can be saved in the button for program-controlled access
Label (String)
button label
Printable (Boolean)
the control element can be printed
State (Short)
if 1, the option is activated, otherwise it is deactivated
RefValue (String)
string for saving additional information (for example, for administrating data record IDs)
TextColor (Long)
text color of control element
HelpText (String)
automatically displayed help text, which is displayed if the mouse cursor is above the control element
HelpURL (String)
URL of online help for the corresponding control element

Text Fields

The model objects of text field forms offer the following properties:

Align (short)
orientation of text (0: left-aligned, 1: centered, 2: right-aligned)
BackgroundColor (long)
background color of control element
Border (short)
type of border (0: no border, 1: 3D border, 2: simple border)
EchoChar (String)
echo character for password field
FontName (String)
name of font type
FontHeight (Single)
height of character in points (pt)
HardLineBreaks (Boolean)
the automatic line breaks are permanently inserted in the text of the control element
HScroll (Boolean)
the text has a horizontal scrollbar
MaxTextLen (Short)
maximum length of text; if 0 is specified, there are no limits
MultiLine (Boolean)
permits multi-line entries
Printable (Boolean)
the control element can be printed
ReadOnly (Boolean)
the content of the control element is read-only
Enabled (Boolean)
the control element can be activated
Tabstop (Boolean)
the control element can be reached through the tab key
TabIndex (Long)
position of the control element in the activation sequence
FontName (String)
name of font type
FontHeight (Single)
height of character in points (pt)
Text (String)
text of control element
TextColor (Long)
text color of control element
VScroll (Boolean)
the text has a vertical scrollbar
HelpText (String)
automatically displayed help text, which is displayed if the mouse cursor is above the control element
HelpURL (String)
URL of online help for the corresponding control element

List Boxes

The model object of the list box forms provides the following properties:

BackgroundColor (long)
background color of control element
Border (short)
type of border (0: no border, 1: 3D frame, 2: simple frame)
FontDescriptor (struct)
structure with details of font to be used (in accordance with com.sun.star.awt.FontDescriptor structure)
LineCount (Short)
number of lines of control element
MultiSelection (Boolean)
permits multiple selection of entries
SelectedItems (Array of Strings)
list of highlighted entries
StringItemList (Array of Strings)
list of all entries
ValueItemList (Array of Variant)
list containing additional information for each entry (for example, for administrating data record IDs)
Printable (Boolean)
the control element can be printed
ReadOnly (Boolean)
the content of the control element is read-only
Enabled (Boolean)
the control element can be activated
Tabstop (Boolean)
the control element can be reached through the tab key
TabIndex (Long)
position of control element in the activation sequence
FontName (String)
name of font type
FontHeight (Single)
height of character in points (pt)
Tag (String)
string containing additional information which can be saved in the button for program-controlled access
TextColor (Long)
text color of control element
HelpText (String)
automatically displayed help text, which is displayed if the mouse cursor is above the control element
HelpURL (String)
URL of online help for the corresponding control element


Documentation note.png VBA : Through their ValueItemList property, list box forms provide a counterpart to the VBA property, ItemData, through which you can administer additional information for individual list entries.

Furthermore, the following methods are provided though the view object of the list box:

addItem (Item, Pos)
inserts the string specified in the Item at the Pos position in the list
addItems (ItemArray, Pos)
inserts the entries listed in the string's ItemArray data field in the list at the Pos position
removeItems (Pos, Count)
removes Count entries as of the Pos position
selectItem (Item, SelectMode)
activates or deactivates the highlighting for the element specified in the string Item depending on the SelectMode variable
makeVisible (Pos)
scrolls through the list field so that the entry specified by Pos is visible
Content on this page is licensed under the Public Documentation License (PDL).