# Control

The **Control** object represents a control on a [script dialog](../../../scripting/script_dialogs); it lets you read and modify a control's value (and contents). Use the [**Dialog**](dialog)**.Control** method to obtain a **Control** object.

| Property Name | Return Type                                                                                                                                                                                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| bg            | _string_                                                                                                                                                                                                            | Set or query the color used for the background (fill) of this control. This is in the format _#RRGGBB_ (hexadecimal) or _RRR,GGG,BBB_ (decimal). Currently only _static text_ and _list view_ controls are supported for this property.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| charcase      | _string_                                                                                                                                                                                                            | For an _edit_ control, gets or sets the control's case setting. Values are **upper**, **lower** and **normal**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| columns       | _object:_[**DialogListColumns**](dialoglistcolumns)                                                                                                                                                                 | For a _list view_ control, returns a [**DialogListColumns**](dialoglistcolumns) object that lets you query or modify the columns in _Details_ mode.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| count         | _int_                                                                                                                                                                                                               | Returns the number of items contained in the control (e.g. in a _combo box_, _list box_ or _list view_, returns the number of items in the list).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| cuetext       | _string_                                                                                                                                                                                                            | Get or set the cue text of a single-line edit control. This is the text shown to help the user when the edit control is empty.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| cx            | _int_                                                                                                                                                                                                               | Set or query the width of the control, in pixels.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| cy            | _int_                                                                                                                                                                                                               | Set or query the height of the control, in pixels.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| enabled       | _bool_                                                                                                                                                                                                              | Set or query the enabled state of the control. Returns **True** if the control is enabled, **False** if it's disabled. You can set this property to change the state.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| fg            | _string_                                                                                                                                                                                                            | Set or query the color used for the text (foreground) of this control. This is in the format _#RRGGBB_ (hexadecimal) or _RRR,GGG,BBB_ (decimal). Currently only _static text_ and _list view_ controls are supported for this property.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| focus         | _bool_                                                                                                                                                                                                              | Set or query the input focus state of the control. Returns **True** if the control currently has input focus, **False** if it doesn't. Set to **True** to give the control input focus.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| image         | <p><em>string</em> or<br><em>object:</em><a href="image"><strong>Image</strong></a></p>                                                                                                                             | For a button or static control set to image mode, this assigns an image to the control. You can either provide a filename (or internal icon name - e.g. `#about` for the internal about icon), or an [**Image**](image) object that you obtained from the [**DOpus**](dopus)**.LoadImage** or [**Script**](script)**.LoadImage** methods.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| label         | <p><em>string</em> or<br><em>object:</em><a href="image"><strong>Image</strong></a></p>                                                                                                                             | <p>Set or query the control's label or title. Not all controls have labels - this will have no effect on controls (like the <em>list view</em>) that don't.</p><p>Note that for <em>combo box</em> controls, this property is only valid for an editable combo - that is, one that you can type your own text into. You can use this property to set or query the current value of the editable text.</p><p>For a static control set to "image" mode, you can also provide an <a href="image"><strong>Image</strong></a> object that you obtained from the <a href="dopus"><strong>DOpus</strong></a><strong>.LoadImage</strong> or <a href="script"><strong>Script</strong></a><strong>.LoadImage</strong> methods. This is the same as using the <code>image</code> property.</p><p>For a <em>tab</em> control, you can set or query the labels of the individual tabs by specifying an index; e.g. <code>Control.label(0)</code> would reference the label of the first tab.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| mode          | _string_                                                                                                                                                                                                            | For a _list view_ control, lets you change or query the current view mode. Valid values are **icon**, **details**, **smallicon**, **list**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| readonly      | _bool_                                                                                                                                                                                                              | Set or query the _read only_ state of an _edit_ control.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| redraw        | _bool_                                                                                                                                                                                                              | Set or query the redraw state of the control. Some controls let you turn off redrawing in order to make multiple changes without visible flicker (for example, adding a large number of items to a _list view_). Set to **False** to turn off redraw, or **True** to turn redraw back on after changing the control.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| rotate        | _int_                                                                                                                                                                                                               | For a _static text_ control set to "image" mode, you can set this property to rotate the displayed image. The value provided is the number of degrees from the image's initial orientation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| style         | _string_                                                                                                                                                                                                            | <p>Set or query the font styles used to display this control's label. The string consists of zero or more characters; valid characters are <strong>b</strong> for bold and <strong>i</strong> for italics.</p><p>Currently only <em>static text</em> controls are supported for this property.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| textbg        | _string_                                                                                                                                                                                                            | <p>Set or query the color used for the text background (fill) of this control. This is in the format <em>#RRGGBB</em> (hexadecimal) or <em>RRR,GGG,BBB</em> (decimal).</p><p>Currently only <em>list view</em> controls are supported for this property.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| title         | <p><em>string</em> or<br><em>object:</em><a href="image"><strong>Image</strong></a></p>                                                                                                                             | Alternative name for the **label** property. The term **title** is used in the dialog editor and XML resources, and can also be used here as a convenience.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| value         | <p><em>string</em> or<br><em>bool</em> or<br><em>int or</em><br><em>object:</em><a href="dialoglistitem"><strong>DialogListItem</strong></a> or<br><em>object:</em><a href="vector"><strong>Vector</strong></a></p> | <p>Set or query the control's value. The meaning of this property depends on the type of the control:</p><ul><li><strong>Edit control</strong>: Returns or accepts a string representing the current contents of the edit control.</li><li><strong>Check box</strong>: For a simple on/off check box, returns or accepts a <em>bool</em> - <strong>True</strong> for checked and <strong>False</strong> for unchecked. For a tri-state check box, returns or accepts an <em>int</em> - <strong>0</strong> for unchecked, <strong>1</strong> for checked and <strong>2</strong> for the indeterminate state.</li><li><strong>Radio button</strong>: Returns or accepts a <em>bool</em> - <strong>True</strong> for checked and <strong>False</strong> for unchecked.</li><li><strong>Tab</strong>: Returns or accepts an <em>int</em> indicating the currently selected page in the tab control.</li><li><strong>List box / combo box / list view</strong>: Returns or accepts a <a href="dialoglistitem"><strong>DialogListItem</strong></a> representing the selected item. When setting the value it also accepts an <em>int</em> representing the 0-based index of the selected item.</li><li><strong>Palette control</strong>: Returns the current color value. The color string is prefixed with a <code>!</code> character if the palette button's checkbox is disabled. You can set the color this way as well. You can also set the value to "enable" or "disable" to change the checkbox state without affecting the color.</li></ul><p>Note that for a multiple-selection <em>list box</em> or <em>list view</em>, this value will return a <a href="vector"><strong>Vector</strong></a> of <a href="dialoglistitem">DialogListItem</a> objects, representing all currently selected items.</p> |
| visible       | _bool_                                                                                                                                                                                                              | Set or query the visible state of the control. Returns **True** if the control is visible and **False** if it's hidden. You can set this property to hide or show the control.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| x             | _int_                                                                                                                                                                                                               | Set or query the left (x) position of the control, in pixels.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| y             | \*int \*                                                                                                                                                                                                            | Set or query the top (y) position of the control, in pixels.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

<table data-header-hidden><thead><tr><th></th><th></th><th></th><th></th></tr></thead><tbody><tr><td>Method Name</td><td><strong>Arguments</strong></td><td>Return Type</td><td>Description</td></tr><tr><td>AddGroup</td><td>&#x3C;string:name><br>&#x3C;int:id><br>[&#x3C;string:flags>]</td><td><em>int</em></td><td><p>Adds a new group to a <em>list view</em> control. Items you add to the list can optionally be placed in groups. Each group must have a unique ID.</p><p>The optional flags are "c" (group is collapsible) and "d" (group starts out collapsed). E.g. <strong>AddGroup("Unimportant", 100, "cd")</strong> would add a group called <em>Unimportant</em> that is initially collapsed.</p></td></tr><tr><td>AddItem</td><td><p>&#x3C;string:name><br>[&#x3C;int:value>]<br>[&#x3C;int:groupid>]</p><p>or</p><p>&#x3C;object:item></p></td><td><em>int</em></td><td><p>Adds a new item to the control (<em>list box</em>, <em>combo box</em> or <em>list view</em>). The first parameter is the item's name, and the optional second parameter is a data value to associate with the item.</p><p>When adding to a grouped <em>list view</em>, the optional third parameter provides the ID of the group you want to add the item to (the second parameter must be provided in this case, and can be set to 0 if no value is required).</p><p>The item is added to the end of the list.</p><p>You can also pass a <a href="dialoglistitem"><strong>DialogListItem</strong></a> object obtained from another control.</p><p>The return value indicates the position in the list of the new item.</p><p>If you are adding to a listview control and need to add an item with multiple columns, you can do it like this (JScript):</p><pre><code>var i = listview.AddItem("This is col 1");
listview.GetItemAt(i).subitems(0) = "This is col 2";
listview.GetItemAt(i).subitems(1) = "This is col 3";
</code></pre></td></tr><tr><td>AutoSize</td><td>[&#x3C;bool:height>]</td><td><em>bool</em></td><td><p>Autosizes the control, if the control type supports autosize. Returns <strong>True</strong> if the control was autosized.</p><p>If the optional <em>height</em> parameter is set to true, the control will be autosized vertically as well as horizontally.</p></td></tr><tr><td>DeselectItem</td><td><p>&#x3C;int:position></p><p>or</p><p>&#x3C;object:item></p></td><td><em>int</em></td><td><p>This method is mainly for use with multiple-selection <em>list box</em> and <em>list view</em> controls. It lets you deselect individual items in the control while leaving other items selected (or unaffected).</p><p>You can specify either the index of the item to select (0 means the first item, 1 means the second and so on) or a <a href="dialoglistitem"><strong>DialogListItem</strong></a> object obtained from the <strong>GetItemAt</strong> or <strong>GetItemByName</strong> methods.</p><p>You can also specify <strong>-1</strong> to deselect all items in the list box.</p></td></tr><tr><td>EnableGroupView</td><td>&#x3C;bool:enable></td><td>none</td><td>Only applies to <em>list view</em> controls. By default group view is off; after adding groups with the <strong>AddGroup</strong> method, use <strong>EnableGroupView</strong> to turn group view on.</td></tr><tr><td>GetGroupById</td><td>&#x3C;int:id></td><td>object:<a href="dialoglistgroup"><strong>DialogListGroup</strong></a></td><td>Returns a **<a href="dialoglistgroup">DialogListGroup</a>**object representing the group with the specified ID that you've previous added to a <em>list view</em> control using the <strong>AddGroup</strong> method.</td></tr><tr><td>GetItemAt</td><td>&#x3C;int:position></td><td>object:<a href="dialoglistitem"><strong>DialogListItem</strong></a></td><td>Returns a <a href="dialoglistitem"><strong>DialogListItem</strong></a> object representing the item contained in the control at the specified index (<em>list box</em>, <em>combo box</em> or <em>list view</em>). Item 0 represents the first item in the list, item 1 the second, and so on.</td></tr><tr><td>GetItemByLabel<br>GetItemByName</td><td>&#x3C;string:name></td><td>object:<a href="dialoglistitem"><strong>DialogListItem</strong></a></td><td>Returns a <a href="dialoglistitem"><strong>DialogListItem</strong></a> object representing the item contained in the control with the specified name (<em>list box, combo box or list view</em>). This method has two names (...<em>Label</em> and ...<em>Name</em>) for historical reasons, you can use either method name interchangeably).</td></tr><tr><td>InsertItemAt</td><td><p>&#x3C;int:position><br>&#x3C;string:name><br>[&#x3C;int:value>]<br>[&#x3C;int:groupid>]</p><p>or</p><p>&#x3C;int:position><br>&#x3C;object:item></p></td><td><em>int</em></td><td><p>Inserts a new item in the control (<em>list box, combo box or list view</em>). The first parameter is the position to insert the item at (0 means the beginning of the list, 1 means the second position and so on). The second parameter is the item's name, and the optional third parameter is a data value to associate with the item.</p><p>When adding to a grouped <em>list view</em>, the optional fourth parameter provides the ID of the group you want to add the item to (the third parameter must be provided in this case, and can be set to 0 if no value is required).</p><p>Instead of the <em>name</em> and <em>value</em> you can also pass a <a href="dialoglistitem"><strong>DialogListItem</strong></a> object obtained from another control.</p><p>The return value indicates the position in the list of the new item.</p></td></tr><tr><td>MoveItem</td><td>&#x3C;int:position><br>or<br>&#x3C;object:item><br>&#x3C;int:newposition></td><td><em>int</em></td><td><p>Moves an existing item to a new location (<em>list box</em>, <em>combo box</em> or <em>list view</em>). The first parameter is the item to move (you can pass either its index or a <a href="dialoglistitem"><strong>DialogListItem</strong></a> object), and the second parameter is the new position the item should be moved to.</p><p>The return value indicates the position in the list of the moved item.</p></td></tr><tr><td>RemoveGroup</td><td>&#x3C;int:id></td><td>none</td><td>Removes the specified group from a <em>list view</em> control.</td></tr><tr><td>RemoveItem</td><td>&#x3C;int:position><br>or<br>&#x3C;object:item></td><td>none</td><td><p>Removes an item from the control (<em>list box, combo box or list view</em>). You can provide either the index of the item to remove (0 means the first item, 1 means the second and so on) or a <a href="dialoglistitem"><strong>DialogListItem</strong></a> object obtained from the <strong>GetItemAt</strong> or <strong>GetItemByName</strong> methods.</p><p>You can also specify <strong>-1</strong> to completely clear the contents of the control, removing all items at once.</p></td></tr><tr><td>SelectItem</td><td>&#x3C;int:position><br>or<br>&#x3C;object:item><br>or <br>&#x3C;string:tab></td><td><em>int</em></td><td><p>Selects an item in the control. For a <em>list box, combo box or list view</em>, you can specify either the index of the item to select (0 means the first item, 1 means the second and so on) or a <a href="dialoglistitem"><strong>DialogListItem</strong></a> object obtained from the <strong>GetItemAt</strong> or <strong>GetItemByName</strong> methods.</p><p>For a multiple-selection <em>list box</em> or <em>list view</em> you can also specify <strong>-1</strong> to select all items in the control.</p><p>For a <em>tab control</em>, you can change which page is visible by specifying the name of the page (i.e. the name of the child dialog) to show.</p><p>The return value indicates the new selected index.</p></td></tr><tr><td>SelectRange</td><td><p>&#x3C;int:start><br>&#x3C;int:end></p><p>or</p><p>&#x3C;object:item1><br>&#x3C;object:item2></p></td><td>object:<a href="vector"><strong>Vector</strong></a></td><td><p>Selects text within an <em>edit control</em> (or the edit field in a <em>combo box</em> control). The two parameters represent the start and end position of the desired selection. To select the entire contents, use <strong>0</strong> for the start and <strong>-1</strong> for the end.</p><p>The return value is a <a href="vector"><strong>Vector</strong></a> with two members that provide the current start and end of the selection. To query the range without changing it, simply call the <strong>SelectRange</strong> method with no arguments.</p><p>In a <em>list box</em> or <em>list view</em> control, this method selects a range of items.</p></td></tr><tr><td>SetFont</td><td>&#x3C;int:id></td><td>none</td><td>Sets the font used by the control to the specified font. The <em>id</em> parameter must have come from a previous call to <a href="dialog"><strong>Dialog</strong></a><strong>.CreateFont</strong>. You can use 0 to reset the font to its default.</td></tr><tr><td>SetItemWidth</td><td>&#x3C;int:width></td><td>none</td><td>Sets the width in pixels of items in a list view control that's set to <strong>list</strong> or <strong>smallicon</strong> mode. Specify <strong>-1</strong> to automatically size the items.</td></tr><tr><td>SetPos</td><td>&#x3C;int:x><br>&#x3C;int:y></td><td>none</td><td>Sets the position of this control. The x and y coordinates are specified in pixels.</td></tr><tr><td>SetPosAndSize</td><td>&#x3C;int:x><br>&#x3C;int:y><br>&#x3C;int:cx><br>&#x3C;int:cy></td><td>none</td><td>Sets the position and size of the control, in a single operation. All coordinates are specified in pixels.</td></tr><tr><td>SetSize</td><td>&#x3C;int:cx><br>&#x3C;int:cy></td><td>none</td><td>Sets the size of this control. The cx (width) and cy (height) values are specified in pixels.</td></tr></tbody></table>
