Common Properties, Events, and Methods

Common Properties, Events, and Methods

Every control in DVX BASIC inherits a set of common properties, events, and methods. These are handled by the form runtime before dispatching to widget-specific interface descriptors.

Common Properties

  Property     Type      R/W   Description
  ----------   -------   ---   -------------------------------------------
  Name         String    R     The control's name (e.g. "Command1"). Read-only at runtime.
  Left         Integer   R/W   X position in pixels relative to the parent container.
  Top          Integer   R/W   Y position in pixels relative to the parent container.
  Width        Integer   R/W   Current width in pixels. Setting this changes the minimum width constraint.
  Height       Integer   R/W   Current height in pixels. Setting this changes the minimum height constraint.
  MinWidth     Integer   R/W   Minimum width for layout. Alias for Width in the setter.
  MinHeight    Integer   R/W   Minimum height for layout. Alias for Height in the setter.
  MaxWidth     Integer   R/W   Maximum width cap (0 = no limit, stretch to fill).
  MaxHeight    Integer   R/W   Maximum height cap (0 = no limit, stretch to fill).
  Weight       Integer   R/W   Layout weight. 0 = fixed size, >0 = share extra space proportionally.
  Visible      Boolean   R/W   Whether the control is visible.
  Enabled      Boolean   R/W   Whether the control accepts user input.
  BackColor    Long      R/W   Background color as a 32-bit ARGB value.
  ForeColor    Long      R/W   Foreground (text) color as a 32-bit ARGB value.
  TabIndex     Integer   R     Accepted for VB compatibility but ignored. DVX has no tab order.

Common Events

These events are wired on every control loaded from a .frm file. Controls created dynamically at runtime via code only receive Click, DblClick, Change, GotFocus, and LostFocus; the keyboard, mouse, and scroll events below require the control to be defined in the .frm file.

  Event       Parameters                                    Description
  ---------   -------------------------------------------   -------------------------------------------
  Click       (none)                                        Fires when the control is clicked.
  DblClick    (none)                                        Fires when the control is double-clicked.
  Change      (none)                                        Fires when the control's value or text changes.
  GotFocus    (none)                                        Fires when the control receives keyboard focus.
  LostFocus   (none)                                        Fires when the control loses keyboard focus.
  KeyPress    KeyAscii As Integer                           Fires when a printable key is pressed. KeyAscii is the ASCII code.
  KeyDown     KeyCode As Integer, Shift As Integer          Fires when any key is pressed down. KeyCode is the scan code; Shift indicates modifier keys.
  KeyUp       KeyCode As Integer, Shift As Integer          Fires when a key is released.
  MouseDown   Button As Integer, X As Integer, Y As Integer Fires when a mouse button is pressed over the control.
  MouseUp     Button As Integer, X As Integer, Y As Integer Fires when a mouse button is released over the control.
  MouseMove   Button As Integer, X As Integer, Y As Integer Fires when the mouse moves over the control.
  Scroll      Delta As Integer                              Fires when the control is scrolled (mouse wheel or scrollbar).

Common Methods

  Method     Parameters   Description
  --------   ----------   -------------------------------------------
  SetFocus   (none)       Gives keyboard focus to this control.
  Refresh    (none)       Forces the control to repaint.

Form

Data Binding

FRM File Format

Form

Form

VB Equivalent: Form -- DVX Widget: Window + VBox/HBox root

The Form is the top-level container representing a DVX window. It is declared in the .frm file with Begin Form FormName. All controls are children of the form's content box, which uses either VBox (default) or HBox layout.

Form Properties

  Property    Type      Default          Description
  ----------  -------   --------------   -------------------------------------------
  Name        String    "Form1"          The form's name, used for event dispatch and Load statement.
  Caption     String    (same as Name)   Window title bar text.
  Width       Integer   400              Window width in pixels. Setting this disables AutoSize.
  Height      Integer   300              Window height in pixels. Setting this disables AutoSize.
  Left        Integer   0                Initial X position. Used when Centered is False.
  Top         Integer   0                Initial Y position. Used when Centered is False.
  Layout      String    "VBox"           Content box layout: "VBox" (vertical) or "HBox" (horizontal).
  AutoSize    Boolean   True             When True, the window shrink-wraps to fit its content.
  Resizable   Boolean   True             Whether the user can resize the window at runtime.
  Centered    Boolean   True             When True, the window is centered on screen. When False, Left/Top are used.

Form Events

  Event         Parameters              Description
  -----------   ---------------------   -------------------------------------------
  Load          (none)                  Fires after the form and all controls are created. This is the default event.
  Unload        (none)                  Fires when the form is being closed or unloaded.
  QueryUnload   Cancel As Integer       Fires before Unload. Set Cancel = 1 to abort the close.
  Resize        (none)                  Fires when the window is resized by the user.
  Activate      (none)                  Fires when the window gains focus.
  Deactivate    (none)                  Fires when the window loses focus.

Form Methods

  Statement           Description
  ------------------  -------------------------------------------
  Load FormName       Load the form (creates the window and controls, fires Load event).
  Unload FormName     Unload the form (fires Unload, destroys window).
  FormName.Show       Make the form visible.
  FormName.Show 1     Show as modal dialog (blocks until closed).
  FormName.Hide       Hide the form without unloading it.

Example

Sub Form_Load ()
    Form1.Caption = "Hello World"
    Print "Form loaded!"
End Sub

Sub Form_QueryUnload (Cancel As Integer)
    If MsgBox("Really quit?", 4) <> 6 Then
        Cancel = 1
    End If
End Sub

Sub Form_Resize ()
    Print "Window resized"
End Sub

Common Properties, Events, and Methods

FRM File Format

CommandButton

CommandButton

VB Equivalent: CommandButton -- DVX Widget: button | Name Prefix: Command

A push button that triggers an action when clicked. Created with wgtButton(parent, text).

Type-Specific Properties

  Property   Type     Description
  --------   ------   -------------------------------------------
  Caption    String   The text displayed on the button. Use & for accelerator keys (e.g. "&OK").

No additional type-specific properties beyond common properties and Caption.

Default Event: Click

Example

Begin Form Form1
    Caption = "Button Demo"
    Begin CommandButton Command1
        Caption = "&Click Me!"
    End
End

Sub Command1_Click ()
    MsgBox "Button was clicked!"
End Sub

Common Properties, Events, and Methods

Label

Label

VB Equivalent: Label -- DVX Widget: label

A static text label. Supports left, center, and right alignment.

Type-Specific Properties

  Property    Type   Description
  ---------   ----   -------------------------------------------
  Caption     String The text displayed by the label.
  Alignment   Enum   Text alignment: Left (default), Center, or Right.

Default Event: Click

Example

Begin Label Label1
    Caption   = "Hello, World!"
    Alignment = "Center"
End

Common Properties, Events, and Methods

TextBox

TextBox

VB Equivalent: TextBox -- DVX Widget: textbox (single-line text input, max 256 chars)

A single-line text input field. Supports data binding via DataSource and DataField properties.

Type-Specific Properties

  Property     Type     Description
  ----------   ------   -------------------------------------------
  Text         String   The text content of the input field.
  DataSource   String   Name of a Data control for data binding.
  DataField    String   Column name for data binding.

Default Event: Change

Example

Begin TextBox Text1
    Text = "Enter text here"
End

Sub Text1_Change ()
    Label1.Caption = "You typed: " & Text1.Text
End Sub

Common Properties, Events, and Methods

Data Binding

TextArea

TextArea

VB Equivalent: TextArea (DVX extension) -- DVX Widget: textarea (multi-line text input, max 4096 chars)

A multi-line text editing area. This is a DVX extension with no direct VB3 equivalent (VB uses a TextBox with MultiLine=True). Supports syntax colorization, line numbers, auto-indent, and find/replace via the C API.

Type-Specific Properties

  Property   Type     Description
  --------   ------   -------------------------------------------
  Text       String   The full text content.

Default Event: Change

Common Properties, Events, and Methods

CheckBox

CheckBox

VB Equivalent: CheckBox -- DVX Widget: checkbox

A toggle control with a label. Checked state is exposed as a Boolean.

Type-Specific Properties

  Property   Type      Description
  --------   -------   -------------------------------------------
  Caption    String    The text displayed next to the checkbox.
  Value      Boolean   True if checked, False if unchecked.

Default Event: Click

Example

Begin CheckBox Check1
    Caption = "Enable feature"
End

Sub Check1_Click ()
    If Check1.Value Then
        Label1.Caption = "Feature ON"
    Else
        Label1.Caption = "Feature OFF"
    End If
End Sub

Common Properties, Events, and Methods

OptionButton

OptionButton

VB Equivalent: OptionButton -- DVX Widget: radio (radio group + radio button) | Name Prefix: Option

A radio button for mutually exclusive choices. DVX uses a radio group container; individual OptionButtons are children of the group. The Value property returns the button's index within its group.

Type-Specific Properties

  Property   Type      Description
  --------   -------   -------------------------------------------
  Caption    String    The text displayed next to the radio button.
  Value      Integer   The index of this radio button within its group (read-only).

Type-Specific Methods

  Method        Parameters          Description
  -----------   -----------------   -------------------------------------------
  SetSelected   Index As Integer    Select the radio button at the given index within the group.

Default Event: Click

Common Properties, Events, and Methods

Frame

Frame

VB Equivalent: Frame -- DVX Widget: frame (titled VBox container)

A container with a titled border. Child controls are placed inside the frame using VBox layout. In the .frm file, nest Begin/End blocks inside the Frame block.

Type-Specific Properties

  Property   Type     Description
  --------   ------   -------------------------------------------
  Caption    String   The title displayed in the frame border.

Container: Yes

Default Event: Click

Example

Begin Frame Frame1
    Caption = "Options"
    Begin CheckBox Check1
        Caption = "Option A"
    End
    Begin CheckBox Check2
        Caption = "Option B"
    End
End

Common Properties, Events, and Methods

VBox

VBox

DVX Extension -- DVX Widget: vbox (vertical layout container)

A container that arranges its children vertically, top to bottom. No title or border. Use Weight on children to distribute extra space.

Container: Yes

Default Event: Click

No type-specific properties.

Common Properties, Events, and Methods

HBox

HBox

HBox

DVX Extension -- DVX Widget: hbox (horizontal layout container)

A container that arranges its children horizontally, left to right. Use Weight on children to distribute extra space.

Container: Yes

Default Event: Click

No type-specific properties.

Common Properties, Events, and Methods

VBox

ListBox

ListBox

VB Equivalent: ListBox -- DVX Widget: listbox

A scrollable list of selectable items. Items are managed via methods (AddItem, RemoveItem, Clear). Supports single and multi-select modes.

Type-Specific Properties

  Property    Type      Description
  ---------   -------   -------------------------------------------
  ListIndex   Integer   Index of the currently selected item (-1 = no selection).
  ListCount   Integer   Number of items in the list (read-only).

Type-Specific Methods

  Method            Parameters                                Description
  ---------------   ---------------------------------------   -------------------------------------------
  AddItem           Text As String                            Add an item to the end of the list.
  RemoveItem        Index As Integer                          Remove the item at the given index.
  Clear             (none)                                    Remove all items from the list.
  List              Index As Integer                          Return the text of the item at the given index.
  SelectAll         (none)                                    Select all items (multi-select mode).
  ClearSelection    (none)                                    Deselect all items.
  SetMultiSelect    Multi As Boolean                          Enable or disable multi-select mode.
  SetReorderable    Reorderable As Boolean                    Enable or disable drag-to-reorder.
  IsItemSelected    Index As Integer                          Returns True if the item at Index is selected.
  SetItemSelected   Index As Integer, Selected As Boolean     Select or deselect a specific item.

Default Event: Click

Example

Sub Form_Load ()
    List1.AddItem "Apple"
    List1.AddItem "Banana"
    List1.AddItem "Cherry"
End Sub

Sub List1_Click ()
    Dim idx As Integer
    idx = List1.ListIndex
    If idx >= 0 Then
        Label1.Caption = "Selected: " & List1.List(idx)
    End If
End Sub

Common Properties, Events, and Methods

ComboBox

DropDown

ComboBox

ComboBox

VB Equivalent: ComboBox -- DVX Widget: combobox (editable text field + drop-down list, max 256 chars)

A combination of a text input and a drop-down list. The user can type text or select from the list. Supports the same AddItem/RemoveItem/Clear/List methods as ListBox.

Type-Specific Properties

  Property    Type      Description
  ---------   -------   -------------------------------------------
  Text        String    The text in the editable field.
  ListIndex   Integer   Index of the currently selected list item (-1 = none).
  ListCount   Integer   Number of items in the drop-down list (read-only).

Type-Specific Methods

Same as .link ctrl.listbox ListBox : AddItem, RemoveItem, Clear, List.

Default Event: Click

Common Properties, Events, and Methods

DropDown

DropDown

DVX Extension -- DVX Widget: dropdown (non-editable drop-down list)

A read-only drop-down list. Unlike ComboBox, the user cannot type free text; they can only select from the provided items. Supports AddItem/RemoveItem/Clear/List.

Type-Specific Properties

  Property    Type      Description
  ---------   -------   -------------------------------------------
  ListIndex   Integer   Index of the currently selected item.
  ListCount   Integer   Number of items (read-only).

Type-Specific Methods

Same as .link ctrl.listbox ListBox : AddItem, RemoveItem, Clear, List.

Default Event: Click

Common Properties, Events, and Methods

HScrollBar

HScrollBar

VB Equivalent: HScrollBar -- DVX Widget: slider | Name Prefix: HScroll

A horizontal slider/scrollbar control. The value ranges between a minimum and maximum set at creation time (default 0 to 100).

Type-Specific Properties

  Property   Type      Description
  --------   -------   -------------------------------------------
  Value      Integer   The current slider position (clamped to min/max range).

Default Event: Change

Example

Begin HScrollBar HScroll1
    MinWidth = 200
End

Sub HScroll1_Change ()
    Label1.Caption = "Value: " & Str$(HScroll1.Value)
End Sub

Common Properties, Events, and Methods

SpinButton

SpinButton

DVX Extension -- DVX Widget: spinner | Name Prefix: Spin

A numeric input with up/down buttons. Supports integer mode (default) and real-number mode with configurable decimal places.

Type-Specific Properties

  Property   Type      Description
  --------   -------   -------------------------------------------
  Value      Integer   Current integer value (in integer mode).
  RealMode   Boolean   True to use floating-point mode; False for integer mode.
  Decimals   Integer   Number of decimal places shown in real mode.

Type-Specific Methods

  Method     Parameters                       Description
  --------   ------------------------------   -------------------------------------------
  SetRange   Min As Integer, Max As Integer   Set the allowed value range.
  SetStep    Step As Integer                  Set the increment per button click.

Default Event: Change

Common Properties, Events, and Methods

Timer

Timer

VB Equivalent: Timer -- DVX Widget: timer (non-visual)

A non-visual control that fires its event at a regular interval. The Timer widget is invisible at runtime -- it has no on-screen representation.

Type-Specific Properties

  Property   Type      Description
  --------   -------   -------------------------------------------
  Enabled    Boolean   True to start the timer, False to stop it.
  Interval   Integer   Timer interval in milliseconds (write-only from BASIC).

Type-Specific Methods

  Method   Parameters   Description
  ------   ----------   -------------------------------------------
  Start    (none)       Start the timer.
  Stop     (none)       Stop the timer.

Type-Specific Events

  Event   Parameters   Description
  -----   ----------   -------------------------------------------
  Timer   (none)       Fires each time the interval elapses. This is the default event.
Note: The Timer control fires the Timer event instead of Change. The onChange callback on the underlying widget is remapped automatically.

Example

Begin Timer Timer1
    Interval = 1000
    Enabled  = True
End

Dim counter As Integer

Sub Timer1_Timer ()
    counter = counter + 1
    Label1.Caption = "Ticks: " & Str$(counter)
End Sub

Common Properties, Events, and Methods

PictureBox

PictureBox

VB Equivalent: PictureBox -- DVX Widget: canvas | Name Prefix: Picture

A drawing surface (canvas). Supports drawing lines, rectangles, circles, text, and individual pixels. Can save and load BMP images. The default canvas size is 64x64 pixels.

Type-Specific Methods

  Method   Parameters         Description
  ------   ----------------   -------------------------------------------
  Clear    Color As Integer   Fill the entire canvas with the specified color.

Additional drawing methods (DrawLine, DrawRect, FillRect, FillCircle, SetPixel, GetPixel, DrawText, Save, Load) are available through the C API but not currently exposed through BASIC interface descriptors.

Default Event: Click

Common Properties, Events, and Methods

Image

Image

VB Equivalent: Image -- DVX Widget: image

A static image display control. Loads BMP images from file. Cannot be placed via the designer toolbox (requires pixel data at creation time); typically created in code or loaded via the Picture property.

Type-Specific Properties

  Property      Type      Description
  -----------   -------   -------------------------------------------
  Picture       String    Path to a BMP file to load (write-only).
  ImageWidth    Integer   Width of the loaded image in pixels (read-only).
  ImageHeight   Integer   Height of the loaded image in pixels (read-only).

Default Event: Click

Common Properties, Events, and Methods

ImageButton

ImageButton

DVX Extension -- DVX Widget: imagebutton

A button that displays an image instead of text. Like Image, it requires pixel data at creation time and is typically loaded via the Picture property.

Type-Specific Properties

  Property      Type      Description
  -----------   -------   -------------------------------------------
  Picture       String    Path to a BMP file to load (write-only).
  ImageWidth    Integer   Width of the loaded image in pixels (read-only).
  ImageHeight   Integer   Height of the loaded image in pixels (read-only).

Default Event: Click

Common Properties, Events, and Methods

ProgressBar

ProgressBar

VB Equivalent: ProgressBar -- DVX Widget: progressbar

A horizontal progress indicator bar.

Type-Specific Properties

  Property   Type      Description
  --------   -------   -------------------------------------------
  Value      Integer   Current progress value (0-100).

No type-specific events or methods. No default event.

Common Properties, Events, and Methods

ListView

ListView

VB Equivalent: ListView -- DVX Widget: listview

A multi-column list with column headers. Supports sorting, multi-select, and drag-to-reorder. Columns are configured via the C API (SetColumns, SetData).

Type-Specific Properties

  Property    Type      Description
  ---------   -------   -------------------------------------------
  ListIndex   Integer   Index of the currently selected row (-1 = none).

Type-Specific Methods

  Method            Parameters                                Description
  ---------------   ---------------------------------------   -------------------------------------------
  SelectAll         (none)                                    Select all rows.
  ClearSelection    (none)                                    Deselect all rows.
  SetMultiSelect    Multi As Boolean                          Enable or disable multi-select.
  SetReorderable    Reorderable As Boolean                    Enable or disable row reordering.
  IsItemSelected    Index As Integer                          Returns True if the row at Index is selected.
  SetItemSelected   Index As Integer, Selected As Boolean     Select or deselect a specific row.

Default Event: Click

Common Properties, Events, and Methods

TreeView

TreeView

VB Equivalent: TreeView -- DVX Widget: treeview

A hierarchical tree of expandable/collapsible nodes. Nodes are created via the C API (wgtTreeItem). Supports multi-select and drag-to-reorder.

Type-Specific Methods

  Method           Parameters               Description
  --------------   ----------------------   -------------------------------------------
  SetMultiSelect   Multi As Boolean         Enable or disable multi-select mode.
  SetReorderable   Reorderable As Boolean   Enable or disable node reordering.

Default Event: Click

Common Properties, Events, and Methods

TabStrip

TabStrip

VB Equivalent: TabStrip -- DVX Widget: tabcontrol

A tabbed container. Each tab page is a separate container that holds child controls. Switching tabs shows one page and hides others.

Type-Specific Properties

  Property   Type      Description
  --------   -------   -------------------------------------------
  TabIndex   Integer   Index of the active tab (0-based). Note: this property name collides with the common VB-compatibility TabIndex property, which shadows it at runtime. Use the SetActive method instead to switch tabs.

Type-Specific Methods

  Method      Parameters          Description
  ---------   -----------------   -------------------------------------------
  SetActive   Index As Integer    Switch to the tab at the given index. This is the recommended way to change tabs at runtime (the TabIndex property is shadowed by the common property handler).

Container: Yes

Default Event: Click

Warning: The TabIndex property is shadowed by the common property handler at runtime. Use the SetActive method to change tabs programmatically.

Common Properties, Events, and Methods

Splitter

Splitter

DVX Extension -- DVX Widget: splitter

A resizable split pane. Holds exactly two child widgets separated by a draggable divider. Default orientation is vertical (top/bottom split).

Type-Specific Properties

  Property   Type      Description
  --------   -------   -------------------------------------------
  Position   Integer   Position of the divider in pixels from the top (or left).

Container: Yes

No default event.

Common Properties, Events, and Methods

ScrollPane

ScrollPane

DVX Extension -- DVX Widget: scrollpane | Name Prefix: Scroll

A scrollable container. Place child controls inside and the ScrollPane automatically provides scrollbars when the content exceeds the visible area.

Type-Specific Properties

  Property   Type      Description
  --------   -------   -------------------------------------------
  NoBorder   Boolean   When True, suppresses the border around the scroll pane.

Container: Yes

No default event.

Common Properties, Events, and Methods

WrapBox

WrapBox

DVX Extension -- DVX Widget: wrapbox

A container that arranges children in a flowing layout, wrapping to the next row when the available width is exceeded. Similar to CSS flexbox with flex-wrap: wrap.

Type-Specific Properties

  Property    Type   Description
  ---------   ----   -------------------------------------------
  Alignment   Enum   Horizontal alignment of items: Left, Center, or Right.

Container: Yes

Default Event: Click

Common Properties, Events, and Methods

Line

Line

VB Equivalent: Line -- DVX Widget: separator

A visual separator line. The underlying widget supports both horizontal and vertical orientations. The default (via BASIC) is horizontal.

No type-specific properties, events, or methods.

Common Properties, Events, and Methods

Spacer

Spacer

DVX Extension -- DVX Widget: spacer

An invisible layout spacer. Takes up space in the layout without rendering anything. Useful for pushing controls apart. Give it a Weight to absorb extra space.

No type-specific properties, events, or methods.

Common Properties, Events, and Methods

Toolbar

Toolbar

VB Equivalent: Toolbar -- DVX Widget: toolbar

A horizontal container styled as a toolbar, with compact padding and spacing. Place buttons, labels, or other controls inside.

Container: Yes

No type-specific properties, events, or methods.

Common Properties, Events, and Methods

StatusBar

StatusBar

VB Equivalent: StatusBar -- DVX Widget: statusbar

A horizontal container styled as a status bar, typically placed at the bottom of a form. At the C API level it accepts child widgets, but it is not registered as a container in the form runtime, so child controls cannot be nested inside it in .frm files. Set its Caption property to display status text.

No type-specific properties, events, or methods.

Common Properties, Events, and Methods

Terminal

Terminal

DVX Extension -- DVX Widget: ansiterm (ANSI terminal emulator)

A VT100/ANSI terminal emulator widget. Supports ANSI escape sequences, scrollback buffer, and serial communication. Default size is 80 columns by 25 rows.

Type-Specific Properties

  Property     Type      Description
  ----------   -------   -------------------------------------------
  Cols         Integer   Number of character columns (read-only).
  Rows         Integer   Number of character rows (read-only).
  Scrollback   Integer   Number of scrollback lines (write-only).

Type-Specific Methods

  Method   Parameters        Description
  ------   ---------------   -------------------------------------------
  Clear    (none)            Clear the terminal screen.
  Write    Text As String    Write text (with ANSI escape processing) to the terminal.

No default event.

Common Properties, Events, and Methods

Data

Data

VB Equivalent: Data -- DVX Widget: data (database record navigator)

A data access control that connects to a SQLite database and provides record navigation. Other controls can bind to a Data control via their DataSource and DataField properties. See .link ctrl.databinding Data Binding for details.

Type-Specific Properties

  Property       Type      R/W   Description
  ------------   -------   ---   -------------------------------------------
  DatabaseName   String    R/W   Path to the SQLite database file.
  RecordSource   String    R/W   Table name or SQL SELECT query for the recordset.
  KeyColumn      String    R/W   Primary key column name (used for UPDATE/DELETE operations).
  Caption        String    R/W   Text displayed on the navigator bar.
  BOF            Boolean   R     True if the current position is before the first record (read-only).
  EOF            Boolean   R     True if the current position is past the last record (read-only).
  MasterSource   String    R/W   Name of a master Data control (for master-detail binding).
  MasterField    String    R/W   Column in the master recordset to filter by.
  DetailField    String    R/W   Column in this recordset that matches the master field.

Type-Specific Methods

  Method         Parameters   Description
  ------------   ----------   -------------------------------------------
  MoveFirst      (none)       Navigate to the first record.
  MoveLast       (none)       Navigate to the last record.
  MoveNext       (none)       Navigate to the next record.
  MovePrevious   (none)       Navigate to the previous record.
  AddNew         (none)       Add a new blank record.
  Delete         (none)       Delete the current record.
  Refresh        (none)       Re-query the database and reload records.
  Update         (none)       Write pending changes to the database.

Type-Specific Events

  Event        Parameters          Description
  ----------   -----------------   -------------------------------------------
  Reposition   (none)              Fires after the current record changes (navigation). This is the default event.
  Validate     Cancel As Integer   Fires before writing a record. Set Cancel = 1 to abort.

Common Properties, Events, and Methods

Data Binding

DBGrid

DBGrid

DBGrid

VB Equivalent: DBGrid -- DVX Widget: dbgrid

A data-bound grid that displays records from a Data control in a tabular format. Columns are auto-generated from the query results. Bind it using the DataSource property.

Type-Specific Properties

  Property     Type      Description
  ----------   -------   -------------------------------------------
  DataSource   String    Name of the Data control that supplies records.
  GridLines    Boolean   Show or hide grid lines between cells.

Type-Specific Methods

  Method    Parameters   Description
  -------   ----------   -------------------------------------------
  Refresh   (none)       Reload and redraw the grid from the Data control.

Type-Specific Events

  Event      Parameters   Description
  --------   ----------   -------------------------------------------
  Click      (none)       Fires when a cell is clicked.
  DblClick   (none)       Fires when a cell is double-clicked. This is the default event.

Common Properties, Events, and Methods

Data

Data Binding

Data Binding

Data Binding

DVX BASIC provides VB3-style data binding through three properties that can be set on most controls:

  Property     Set On        Description
  ----------   -----------   -------------------------------------------
  DataSource   Any control   Name of the Data control to bind to (e.g. "Data1").
  DataField    Any control   Column name from the Data control's recordset to display.

How It Works

When a bound control loses focus (LostFocus), its current text is written back to the Data control's record cache, and Update is called automatically to persist changes.

Master-Detail Binding

For hierarchical data (e.g. orders and order items), use two Data controls:

A detail Data control with its MasterSource set to the master's name, MasterField set to the key column in the master, and DetailField set to the foreign key column in the detail table.

When the master record changes, the detail Data control automatically re-queries using the master's current value for filtering. All controls bound to the detail are refreshed.

DBGrid Binding

Set the DBGrid's DataSource to a Data control name. The grid auto-populates columns from the query results and refreshes whenever the Data control refreshes.

Example

VERSION DVX 1.00
Begin Form frmData
    Caption      = "Data Binding Example"
    AutoSize     = False
    Width        = 400
    Height       = 280
    Begin Data Data1
        DatabaseName = "myapp.db"
        RecordSource = "customers"
    End
    Begin Label lblName
        Caption = "Name:"
    End
    Begin TextBox txtName
        DataSource = "Data1"
        DataField  = "name"
    End
    Begin Label lblEmail
        Caption = "Email:"
    End
    Begin TextBox txtEmail
        DataSource = "Data1"
        DataField  = "email"
    End
End

Sub Data1_Reposition ()
    Print "Current record changed"
End Sub

Sub Data1_Validate (Cancel As Integer)
    If txtName.Text = "" Then
        MsgBox "Name cannot be empty!"
        Cancel = 1
    End If
End Sub

Data

DBGrid

Menu System

Menu System

Menus are defined in the .frm file using Begin Menu blocks. Each menu item has a name, caption, and nesting level. Menu items fire Click events dispatched as MenuName_Click.

FRM Syntax

Begin Form Form1
    Caption = "Menu Demo"

    Begin Menu mnuFile
        Caption = "&File"
        Begin Menu mnuOpen
            Caption = "&Open"
        End
        Begin Menu mnuSave
            Caption = "&Save"
        End
        Begin Menu mnuSep1
            Caption = "-"
        End
        Begin Menu mnuExit
            Caption = "E&xit"
        End
    End

    Begin Menu mnuEdit
        Caption = "&Edit"
        Begin Menu mnuCopy
            Caption = "&Copy"
        End
        Begin Menu mnuPaste
            Caption = "&Paste"
        End
    End
End

Menu Item Properties

  Property   Type      Description
  --------   -------   -------------------------------------------
  Caption    String    The text displayed. Use & for accelerator key. Set to "-" for a separator.
  Checked    Boolean   Whether the menu item shows a checkmark.
  Enabled    Boolean   Whether the menu item is enabled (default True).

Nesting

Menu items are nested by placing Begin Menu blocks inside other Begin Menu blocks:

Level 2+: submenu items.

A level-0 menu that contains children becomes a top-level menu header. A non-level-0 menu that contains children becomes a submenu.

Event Dispatch

Each clickable menu item (not headers, not separators) receives a unique numeric ID at load time. When clicked, the form's onMenu handler maps the ID to the menu item's name and fires MenuName_Click.

Sub mnuOpen_Click ()
    MsgBox "Open was clicked"
End Sub

Sub mnuExit_Click ()
    Unload Form1
End Sub

Form

FRM File Format

Control Arrays

Control Arrays

DVX BASIC supports VB-style control arrays. Multiple controls can share the same name, differentiated by an Index property. When an event fires on a control array element, the element's index is passed as the first parameter.

Defining Control Arrays in FRM

Begin CommandButton Command1
    Caption = "Button A"
    Index   = 0
End
Begin CommandButton Command1
    Caption = "Button B"
    Index   = 1
End
Begin CommandButton Command1
    Caption = "Button C"
    Index   = 2
End

Event Handler Convention

When a control has an Index property (>= 0), the event handler receives Index As Integer as the first parameter, before any event-specific parameters.

Sub Command1_Click (Index As Integer)
    Select Case Index
        Case 0
            MsgBox "Button A clicked"
        Case 1
            MsgBox "Button B clicked"
        Case 2
            MsgBox "Button C clicked"
    End Select
End Sub

Accessing Array Elements in Code

Use the indexed form ControlName(Index) to access a specific element:

Command1(0).Caption = "New Text"
Command1(1).Enabled = False
Note: Control array elements share the same event handler Sub. The runtime prepends the Index argument automatically. If you define parameters on the Sub, Index comes first, followed by the event's own parameters (e.g. KeyPress would be Sub Ctrl1_KeyPress (Index As Integer, KeyAscii As Integer)).

Common Properties, Events, and Methods

FRM File Format

FRM File Format

FRM File Format

The .frm file is a text file that describes a form's layout, controls, menus, and code. It follows a format compatible with VB3 .frm files, with DVX-specific extensions.

Structure

VERSION DVX 1.00
Begin Form FormName
    form-level properties...

    Begin Menu mnuFile
        Caption = "&File"
        Begin Menu mnuOpen
            Caption = "&Open"
        End
    End

    Begin TypeName ControlName
        property = value
        ...
    End

    Begin Frame Frame1
        Caption = "Group"
        Begin TypeName ChildName
            ...
        End
    End
End

BASIC code follows...

Sub FormName_Load ()
    ...
End Sub

Rules

Blank lines are ignored in the form section.

Common FRM Properties

  Property                  Applies To        Description
  -----------------------   ---------------   -------------------------------------------
  Caption                   Form, controls    Display text or window title.
  Text                      TextBox, ComboBox Initial text content.
  MinWidth / Width          Controls          Minimum width. Both names are accepted.
  MinHeight / Height        Controls          Minimum height. Both names are accepted.
  MaxWidth                  Controls          Maximum width (0 = no cap).
  MaxHeight                 Controls          Maximum height (0 = no cap).
  Weight                    Controls          Layout weight for flexible sizing.
  Left                      Form, controls    X position (used by Form when Centered=False; informational for controls).
  Top                       Form, controls    Y position.
  Index                     Controls          Control array index (-1 or absent = not in array).
  Visible                   Controls          Initial visibility.
  Enabled                   Controls          Initial enabled state.
  Layout                    Form              "VBox" or "HBox".
  AutoSize                  Form              Auto-fit window to content.
  Resizable                 Form              Allow runtime resizing.
  Centered                  Form              Center window on screen.
  DatabaseName              Data              SQLite database file path.
  RecordSource              Data              Table name or SQL query.
  DataSource                Bound controls    Name of the Data control.
  DataField                 Bound controls    Column name in the recordset.

Form

Common Properties, Events, and Methods

Menu System

Control Arrays