2KEBr‖SFDialogs.DialogControl service

RDcyi‖The DialogControl service manages the controls belonging to a dialog defined with the Basic Dialog Editor. Each instance of the current service represents a single control within a dialog box.

7dDgL‖The focus is set on getting and setting the values displayed by the controls of the dialog box. Formatting is accessible via the XControlModel and XControlView properties.

fFfwe‖Note that the unique DialogControl.Value property content varies according to the control type.

MBrzA‖A special attention is given to controls of type tree control. It is easy to populate a tree, either branch by branch, or with a set of branches at once. Populating a tree control can be performed statically or dynamically.

tip

hag3A‖The SFDialogs.DialogControl service is closely related to the SFDialogs.Dialog service.


uGTGK‖Service invocation

LGkgR‖Before using the DialogControl service the ScriptForge library needs to be loaded or imported:

note

gF8D8‖• Basic macros require to load ScriptForge library using the following statement:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")

• Python scripts require an import from scriptforge module:
from scriptforge import CreateScriptService


EnxDs‖The DialogControl service is invoked from an existing Dialog service instance through its Controls() method. The dialog must be initiated with the SFDialogs.Dialog service.


      Dim myDialog As Object, myControl As Object
      Set myDialog = CreateScriptService("SFDialogs.Dialog", "GlobalScope", myLibrary, DialogName)
      Set myControl = myDialog.Controls("myTextBox")
      RCFrE‖myControl.Value = "Dialog started at " & Now()
      myDialog.Execute()
      WVG8J‖' ... process the controls actual values
      myDialog.Terminate()
   

     from time import localtime, strftime
     dlg = CreateScriptService('SFDialogs.Dialog', 'GlobalScope', lib_name, dlg_name)
     text = dlg.Controls('myTextBox')
     gxhUu‖text.Value = "Dialog started at " + strftime("%a, %d %b %Y %H:%M:%S", localtime())
     dlg.Execute()
     nu3f3‖# ... process the controls actual values
     dlg.Terminate()
   

GZ3ia‖Retrieving the DialogControl instance that triggered a control event

CcXYE‖An instance of the DialogControl service can be retrieved via the SFDialogs.DialogEvent service, provided that the dialog was initiated with the Dialog service. In the example below, oControl contains the DialogControl instance that triggered the control event.


      Sub aControlEventHandler(ByRef poEvent As Object)
          Dim oControl As Object
          Set oControl = CreateScriptService("SFDialogs.DialogEvent", poEvent)
          ' ...
      End Sub
  

jeLRp‖Or using Python:


     def control_event_handler(event: uno):
         oControl = CreateScriptService('SFDialogs.DialogEvent', event)
         # ...
  

EroTy‖Note that in the previous examples, the prefix "SFDialogs." may be omitted when deemed appropriate.

KazD8‖Handling exceptions in event handlers

isdwE‖When creating an event handler for control events it is good practice to handle errors inside the subroutine itself. For instance, suppose the event handler below is called when button is clicked.


    Sub OnButtonClicked(ByRef oEvent As Object)
    On Local Error GoTo Catch
        Dim oControl As Object
        oControl = CreateScriptService("DialogEvent", oEvent)
    a9jEq‖    ' Process the event
        Exit Sub
    Catch:
        MsgBox SF_Exception.Description
        SF_Exception.Clear
    End Sub
  
tip

wUTZB‖Call SF_Exception.Clear if you do not want the error to propagate after the dialog execution ended.


GVfqQ‖In Python use native try/except blocks for exception handling as shown below:


    def on_button_clicked(event=None):
        try:
            oControl = CreateScriptService("DialogEvent", event)
    hMJjt‖        # Process the event
        except Exception as e:
    WEjXM‖        # The object "bas" below is an instance of the Basic service
            bas.MsgBox(str(e))
  

F9uKj‖Control types

jKJBV‖The DialogControl service is available for these control types:

• Button
• CheckBox
• ComboBox
• CurrencyField
• DateField
• FileControl

• FixedLine
• FixedText
• FormattedField
• GroupBox
• Hyperlink
• ImageControl

• ListBox
• NumericField
• PatternField
• ProgressBar
• RadioButton
• ScrollBar

• TableControl
• TabPageContainer
• TextField
• TimeField
• TreeControl


note

Lc2Ma‖TabPageContainer control type is not defined in the Dialog Editor.


7xddb‖Properties

94RMV‖Name

eccsg‖ReadOnly

KRYNv‖Type

U9ZYU‖Applicable to

emDac‖Description

Border

cAKRH‖Yes

String

Button, …

KfD9d‖The Border property refers to the surrounding of the control: "3D", "FLAT" or "NONE".

Cancel

xNGhR‖No

Boolean

Button

aTyMC‖Specifies if a command button has or not the behaviour of a Cancel button.

Caption

Gft3Z‖No

String

Button, CheckBox, FixedLine, FixedText, GroupBox, Hyperlink, RadioButton

UXoyn‖Specifies the text associated with the control.

ControlType

Uo2SP‖Yes

String

YKEAg‖All

c5GAw‖One of the types listed above.

CurrentNode

oMipU‖No

59ovD‖UNO
object

TreeControl

tM7T7‖The currently upmost node selected in the tree control. Refer to XmutableTreeNode in Application Programming Interface (API) documentation for detailed information.

Default

veivJ‖No

Boolean

Button

y2irQ‖Specifies whether a command button is the default (OK) button.

Enabled

GAdvJ‖No

Boolean

tBmrq‖All

8S9xG‖Specifies if the control is accessible with the cursor.

Format

2E9Cb‖No

String

DateField, TimeField, FormattedField

6L9ke‖(read-only)

QbN5U‖Specifies the format used to display dates and times. It must be one these strings:

5eRkE‖For dates: "Standard (short)", "Standard (short YY)", "Standard (short YYYY)", "Standard (long)", "DD/MM/YY", "MM/DD/YY", "YY/MM/DD", "DD/MM/YYYY", "MM/DD/YYYY" , "YYYY/MM/DD", "YY-MM-DD", "YYYY-MM-DD".

CDCLC‖For times: "24h short", "24h long", "12h short", "12h long".

ListCount

nLCxq‖Yes

Long

ComboBox, ListBox, TableControl

rDJFC‖Specifies the number of rows in a ListBox, a ComboBox or a TableControl.

ListIndex

kaaLt‖No

Long

ComboBox, ListBox, TableControl

Ey9iG‖Specifies which item is selected in a ListBox, a ComboBox or a TableControl.

Locked

azv7C‖No

Boolean

ComboBox, CurrencyField, DateField, FileControl, FormattedField, ListBox, NumericField, PatternField, TextField, TimeField

6N6Eb‖Specifies if the control is read-only.

MultiSelect

bubBB‖No

Boolean

ListBox

r83sC‖Specifies whether a user can make multiple selections in a listbox.

Name

BBJCw‖Yes

String

uHsgi‖All

HLjFU‖The name of the control.

Page

jSSnv‖No

Integer

8GZkA‖All

BdxvF‖A dialog may have several pages that can be traversed by the user step by step. The Page property of the Dialog object defines which page of the dialog is active.

isrYW‖The Page property of a control defines the page of the dialog on which the control is visible.

Parent

Cj3Kq‖Yes

6EFh7‖Dialog
service

SDCx4‖All

sqEuV‖The parent SFDialogs.Dialog class object instance.

Picture

GTGu9‖No

String

Button, ImageControl

LP96H‖Specifies the file name containing a bitmap or other type of graphic to be displayed on the specified control. The filename must comply with the FileNaming attribute of the ScriptForge.FileSystem service.

RootNode

LZLsc‖Yes

QxAW9‖UNO
object

TreeControl

m4uz7‖An object representing the lowest root node (usually there is only one such root node). Refer to XmutableTreeNode in Application Programming Interface (API) documentation for detailed information.

RowSource

PqsSY‖No

Array of strings

ComboBox, ListBox

AciNr‖Specifies the data contained in a combobox or a listbox.

TabIndex

PmMEu‖Yes

Numeric

All

PEFC6‖The TabIndex property specifies a control's place in the tab order in the dialog.

Text

q532w‖Yes

String

ComboBox, FileControl, FormattedField, PatternField, TextField

4h8VF‖Gives access to the text being displayed by the control.

TipText

We5gv‖No

String

EijF2‖All

CbBZJ‖Specifies the text that appears as a tooltip when you hold the mouse pointer over the control.

TripleState

kVtki‖No

Boolean

CheckBox

ZemBe‖Specifies if the checkbox control may appear dimmed (grayed) or not.

URL

rZGBG‖No

String

Hyperlink

MmMXv‖The URL to open when the control is clicked.

Value

BDWA7‖No

Variant

GYx9T‖Refer to Value property

Visible

PqKgo‖No

Boolean

8r3sG‖All

xLL83‖Specifies if the control is hidden or visible.

XControlModel

Xw6X9‖Yes

dBNCA‖UNO
object

gbjHB‖All

Erxx8‖The UNO object representing the control model. Refer to XControlModel and UnoControlDialogModel in Application Programming Interface (API) documentation for detailed information.

XControlView

xfhaP‖Yes

o2H9W‖UNO
object

rrwm6‖All

TCTcr‖The UNO object representing the control view. Refer to XControl and UnoControlDialog in Application Programming Interface (API) documentation for detailed information.

XTreeDataModel

SAkJX‖Yes

yuAdF‖UNO
object

TreeControl

s7nM8‖The UNO object representing the tree control data model. Refer to XMutableTreeDataModel in Application Programming Interface (API) documentation for detailed information.

XGridColumnModel

xpodm‖Yes

DnKXu‖UNO
object

TableControl

ssCz8‖The UNO object representing the table control data model. Refer to XGridColumnModel in Application Programming Interface (API) documentation for detailed information.

XGridDataModel

LSAeK‖Yes

sFVoA‖UNO
object

TableControl

EB9tC‖The UNO object representing the tree control data model. Refer to XGridDataModel in Application Programming Interface (API) documentation for detailed information.


VLPsS‖The Value property

JHK7w‖Control type

33wWa‖Type

QLVMB‖Description

Button

Boolean

jEyx9‖For toggle buttons only

CheckBox

gCWiY‖Boolean or Integer

7GZGS‖0, False: not checked
1, True: checked
2: grayed, don't know

ComboBox

String

nZVA5‖The selected value. The ListIndex property is an alternate option.

CurrencyField

MWkEW‖Numeric

DateField

Date

FileControl

String

kgfXR‖A file name formatted in accordance with the FileNaming property of the ScriptForge.FileSystem service

FormattedField

9NVHN‖String or Numeric

ListBox

53Ztp‖String or array of strings

9NwJs‖The selected row(s) as a scalar or as an array depending on the MultiSelect attribute

NumericField

tFGhf‖Numeric

PatternField

String

ProgressBar

YvPAp‖Numeric

fBArb‖Must be within the predefined bounds

RadioButton

Boolean

ZragT‖Each button has its own name. They are linked together if their TAB positions are contiguous. If a radiobutton is set to True, the other related buttons are automatically set to False

ScrollBar

m6Uyb‖Numeric

MWdGb‖Must be within the predefined bounds

TabPageContainer

Numeric

XEDFW‖A dialog may have several numbered tabs identifiable or modifiable by their Value property.

TableControl

Array

CVTcE‖One-dimensional array with the data of the currently selected row.

TextField

String

a9AMF‖The text appearing in the field

TimeField

Date


note

NQJq7‖There is no Value property for GroupBox, Hyperlink, ImageControl and TreeControl dialog controls.


CABLr‖Event properties

DBz57‖On… event properties are URI strings that reference a script triggered for an event. Read its specification in the scripting framework URI specification.

hoRsE‖Name (event API link)

2A2Ex‖Description as labeled in the Basic IDE

OnActionPerformed

aABgD‖Execute action

OnAdjustmentValueChanged

JrRob‖While adjusting

OnFocusGained

7Swj5‖When receiving focus

OnFocusLost

ozGia‖When losing focus

OnItemStateChanged

HREcr‖Item status changed

OnKeyPressed

sVo6A‖Key pressed

OnKeyReleased

P6NX8‖Key released

OnMouseDragged

oCDXm‖Mouse moved while key presses

OnMouseEntered

9XdcG‖Mouse inside

OnMouseExited

mzbBD‖Mouse outside

OnMouseMoved

OnMousePressed

8B9ct‖Mouse button pressed

OnMouseReleased

4c5qE‖Mouse button released

OnNodeExpanded

VudpK‖(Not in Basic IDE) when the expansion button is pressed on a node in a tree control

OnNodeSelected

quWBQ‖(Not in Basic IDE) when a node in a tree control is selected

OnTabSelected

vm5hx‖(Not in Basic IDE) when a tab in a TabPage control is selected

OnTextChanged

th6Kr‖Text modified


tip

iVjnF‖Tip: All On… properties can be set programmatically.
How to display data in a tree control example in LibreOfficeDev Wiki demonstrates such.


warning

Z4Lnx‖Assigning events via the Basic IDE and assigning events via macros are mutually exclusive.


YFbGT‖Methods

xNrc5‖List of Methods in the DialogControl Service

AddSubNode
AddSubTree
CreateRoot

FindNode
Resize
SetFocus

SetTableData
WriteLine


AddSubNode

uHbTG‖Create and return a new node of the tree control as a UNO object subordinate to a parent node. Refer to XMutableTreeNode in Application Programming Interface (API) documentation for detailed information.

MrQnS‖This method may be called before displaying the dialog box to build the initial tree. It may also be called from a dialog or control event - using the OnNodeExpanded event - to complete the tree dynamically.

FVEx2‖Syntax:

svc.AddSubNode(parentnode: uno, displayvalue: str, opt datavalue: any): uno

WADQ4‖Parameters:

T8xdA‖parentnode: A node UNO object, of type com.sun.star.awt.tree.XMutableTreeNode.

qJ9ej‖displayvalue: The text appearing in the tree control box.

Pzz72‖datavalue: Any value associated with the new node. datavalue may be a string, a number or a date. Omit the argument when not applicable.

EFSA4‖Example:

2pLPL‖LibreOfficeDev Basic and Python examples pick up current document's myDialog dialog from Standard library.

3aa4B‖In Basic

      Dim oDlg As Object, myTree As Object, myNode As Object, theRoot As Object
      Set oDlg = CreateScriptService("Dialog",,, "myDialog")
      Set myTree = oDlg.Controls("myTreeControl")
      Set theRoot = myTree.CreateRoot("Tree top")
      Set myNode = myTree.AddSubNode(theRoot, "A branch ...")
   
BenDd‖In Python

     dlg = CreateScriptService('SFDialogs.Dialog', None, None, 'myDialog')
     tree = dlg.Controls('myTreeControl')
     root = tree.CreateRoot('Tree top')
     node = tree.AddSubNode(root, 'A branch ...')
   

AddSubTree

8B3qP‖Return True when a subtree, subordinate to a parent node, could be inserted successfully in a tree control. If the parent node had already child nodes before calling this method, the child nodes are erased.

MrQnS‖This method may be called before displaying the dialog box to build the initial tree. It may also be called from a dialog or control event - using the OnNodeExpanded event - to complete the tree dynamically.

FVEx2‖Syntax:

svc.AddSubTree(parentnode: uno, flattree: any, opt withdatavalue: bool): bool

WADQ4‖Parameters:

beond‖parentnode: A node UNO object, of type com.sun.star.awt.tree.XMutableTreeNode.

QJ73V‖flattree: a two dimension array sorted on the columns containing the display values. Such an array can be issued by the GetRows method applied on the SFDatabases.Database service. When an array item containing the text to be displayed is Empty or Null, no new subnode is created and the remainder of the row is skipped.


      r5QNj‖Flat tree    >>>>    Resulting subtree
      A1	B1	C1             |__   A1	
      A1	B1	C2                   |__   B1
      A1	B2	C3                         |__  C1
      A2	B3	C4                         |__  C2
      A2	B3	C5                   |__   B2
      A3	B4	C6                         |__  C3
                             |__   A2
                                   |__   B3
                                         |__  C4
                                         |__  C5
                             |__   A3
                                   |__   B4
                                         |__  C6
   

MUi8U‖withdatavalue: When False default value is used, every column of flattree contains the text to be displayed in the tree control. When True, the texts to be displayed (displayvalue) are in columns 0, 2, 4, ... while the data values (datavalue) are in columns 1, 3, 5, ...

EFSA4‖Example:

3aa4B‖In Basic

      Dim myTree As Object, theRoot As Object, oDb As Object, vData As Variant
      Set myTree = myDialog.Controls("myTreeControl")
      Set theRoot = myTree.CreateRoot("By product category")
      Set oDb = CreateScriptService("SFDatabases.Database", "/home/.../mydatabase.odb")
      vData = oDb.GetRows("SELECT [Category].[Name], [Category].[ID], [Product].[Name], [Product].[ID] " _
          & "FROM [Category], [Product] WHERE [Product].[CategoryID] = [Category].[ID] " _
          & "ORDER BY [Category].[Name], [Product].[Name]")
      myTree.AddSubTree(theRoot, vData, WithDataValue := True)
   
BenDd‖In Python

     SQL_STMT = "SELECT [Category].[Name], [Category].[ID], [Product].[Name], [Product].[ID] \
         FROM [Category], [Product] WHERE [Product].[CategoryID] = [Category].[ID] \
         ORDER BY [Category].[Name], [Product].[Name]"
     tree = dlg.Controls('myTreeControl')
     root = tree.CreateRoot('By Product category')
     db = CreateScriptService('SFDatabases.Database', '/home/.../mydatabase.odb')
     sub_tree = db.GetRows(SQL_STMT)
     tree.AddSubTree(root, sub_tree, withdatavalue=True)
   

CreateRoot

fWnhZ‖Returns a new root node of the tree control, as a node UNO object of type com.sun.star.awt.tree.XMutableTreeNode. The new tree root is inserted below pre-existing root nodes. Refer to XMutableTreeNode in Application Programming Interface (API) documentation for detailed information.

YT845‖This method may be called before displaying the dialog box to build the initial tree. It may also be called from a dialog or control event to complete the tree dynamically.

FVEx2‖Syntax:

svc.CreateRoot(displayvalue: str, opt datavalue: any): uno

WADQ4‖Parameters:

JXyjD‖displayvalue: The text appearing in the tree control box.

Pzz72‖datavalue: Any value associated with the new node. datavalue may be a string, a number or a date. Omit the argument when not applicable.

EFSA4‖Example:

3aa4B‖In Basic

      Dim myTree As Object, myNode As Object
      Set myTree = myDialog.Controls("myTreeControl")
      Set myNode = myTree.CreateRoot("Tree starts here ...")
   
BenDd‖In Python

     tree = dlg.Controls('myTreeControl')
     node = tree.CreateRoot('Tree starts here ...')
   

FindNode

XxGFd‖Traverses the tree and finds recursively, starting from the root, a node meeting some criteria. Either - 1 match is enough - having its display value matching displayvalue pattern or having its data value equal to datavalue. The comparisons may be or not case-sensitive. The first matching occurrence is returned as a node UNO object of type com.sun.star.awt.tree.XMutableTreeNode. Refer to XMutableTreeNode in Application Programming Interface (API) documentation for detailed information.

5Jxkj‖When not found, the method returns Nothing, to be tested with the IsNull() builtin function.

n7pE8‖This method may be called before displaying the dialog box to build the initial tree. It may also be called from a dialog or control event.

FVEx2‖Syntax:

svc.FindNode(displayvalue: str = '', opt datavalue: any, casesensitive = False): uno

WADQ4‖Parameters:

Dd4Ti‖One argument out of displayvalue or datavalue must be specified. If both present, one match is sufficient to select the node.

4xxwd‖displayvalue: The pattern to be matched. Refer to SF_String.IsLike() method for the list of possible wildcards. When equal to the zero-length string (default), this display value is not searched for.

Pzz72‖datavalue: Any value associated with the new node. datavalue may be a string, a number or a date. Omit the argument when not applicable.

BE58W‖casesensitive: Default value is False

EFSA4‖Example:

3aa4B‖In Basic

      Dim myTree As Object, myNode As Object
      Set myTree = myDialog.Controls("myTreeControl")
      Set myNode = myTree.FindNode("*Sophie*", CaseSensitive := True)
   
BenDd‖In Python

     tree = dlg.Controls('myTreeControl')
     node = FindNode('*Sophie*', casesensitive=True)
     if node is None:
         # ...
   

Resize

tCfF4‖Move the top-left corner of a dialog control to new coordinates and/or modify its dimensions. Return True if resizing was successful.

FVEx2‖Syntax:

svc.Resize(opt Left: int, opt Top: int, opt Width: int, opt Height: int): bool

WADQ4‖Parameters:

pzYAg‖All distances are expressed in Map AppFont units and are measured from the top-left corner of the parent dialog. Without arguments the method resizes the control to its "preferred size", a size adjusted depending on its actual content. Missing arguments are left unchanged.

7RcPA‖Left: The horizontal distance from the top-left corner

n6cEo‖Top: The vertical distance from the top-left corner

EpNL7‖Width: the horizontal width of the rectangle containing the control

RMsh8‖Height: the vertical height of the rectangle containing the control

EFSA4‖Example:

3aa4B‖In Basic

      Dim oControl As Object
      Set oDlg = CreateScriptService("SFDialogs.Dialog",,, "myDialog")
      Set oControl = oDlg.Controls("thisControl")
      k6MEJ‖oControl.Resize(100, 200, Height:=6000) ' Width is unchanged
    
BenDd‖In Python

      dlg = CreateScriptService('Dialog', None, None, 'myDialog')
      ctrl = dlg.Controls('thisControl')
      Cay6f‖ctrl.Resize(300, 200, 1500)  # Height is unchanged
    

SetFocus

3oU3L‖Set the focus on the control. Return True if focusing was successful.

6YvuU‖This method is often called from a dialog or control event.

FVEx2‖Syntax:

svc.SetFocus(): bool

EFSA4‖Example:

3aa4B‖In Basic

      Dim oControl As Object
      Set oDlg = CreateScriptService("SFDialogs.Dialog",,, "myDialog")
      Set oControl = oDlg.Controls("thisControl")
      oControl.SetFocus()
    
BenDd‖In Python

      dlg = CreateScriptService('Dialog', None, None, 'myDialog')
      ctrl = dlg.Controls('thisControl')
      ctrl.SetFocus()
    

SetTableData

it2QN‖Fills a TableControl with the given data. All preexisting data is cleared before inserting the new data passed as argument.

Vmmag‖When the TableControl is added to the dialog, it is possible to use the Basic IDE to define whether column and row headers will be shown in the table. If the TableControl has column and/or row headers, the first column and/or row in the provided data array are used as labels for the table headers.

qn4UN‖This method returns True when successful.

FVEx2‖Syntax:

svc.SetTableData(dataarray: any[0..*, 0..*], widths: int[0..*], alignments: str, RowHeaderWidth = 10): bool

WADQ4‖Parameters:

LESVB‖dataarray: Data to be entered into the table represented as an Array of Arrays in Basic or a tuple of tuples in Python. The data must include column and row headers if they are to be displayed by the TableControl.

zGc73‖widths: Array containing the relative widths of each column. In other words, widths = (1, 2) means that the second column is twice as wide as the first one. If the number of values in the array is smaller than the number of columns in the table, then the last value in the array is used to define the width of the remaining columns.

AEGq3‖alignments: Defines the alignment in each column as a string in which each character can be "L" (Left), "C" (Center), "R" (Right) or " " (whitespace, default, meaning left for strings and right for numeric values). If the length of the string is shorter than the number of columns in the table, then the last character in the string is used to define the alignment of the remaining columns.

i3UBY‖RowHeaderWidth: width of the row header column expressed in Map AppFont units. Default = 10. The argument is ignored when the TableControl has no row header.

EFSA4‖Example:

3aa4B‖In Basic

CK6RC‖The following example assumes that the dialog myDialog has a TableControl named Grid1 with "Show row header" and "Show column header" properties set to "Yes".


     Dim myDialog As Object, oTable As Object, tableData As Variant
     myDialog = CreateScriptService("Dialog", "GlobalScope", "Standard", "myDialog")
     oTable = myDialog.Controls("Grid1")
     tableData = Array("Column A", "Column B", "Column C")
     tableData = SF_Array.AppendRow(tableData, Array("Row 1", 1, 2))
     tableData = SF_Array.AppendRow(tableData, Array("Row 2", 3, 4))
     tableData = SF_Array.AppendRow(tableData, Array("Row 3", 5, 6))
     vAlignments = "LCC"
     vWidths = Array(2, 1, 1)
     oTable.SetTableData(tableData, vWidths, vAlignments)
     myDialog.Execute()
   

N9Byz‖The Value property returns the selected row in the table. If no row is selected, an empty Array object is returned. The following code snippet shows how to test if any row is selected in the table.


     rowValues = oTable.Value
     If UBound(rowValues) < 0 Then
     CEK7w‖    MsgBox "No row selected."
     Else
     N9fG7‖    MsgBox "Row " & oTable.ListIndex & " is selected."
     End If
   
BenDd‖In Python

     dlg = CreateScriptService("Dialog", "GlobalScope", "Standard", "myDialog")
     table_control = dlg.Controls("Grid1")
     table_data = (("Column A", "Column B", "Column C"),
                   ("Row 1", 1, 2),
                   ("Row 2", 3, 4),
                   ("Row 3", 5, 6))
     alignments = "LCC"
     widths = (100, 50, 50)
     table_control.SetTableData(table_data, widths, alignments)
     dlg.Execute()
   

     bas = CreateScriptService("Basic")
     row_values = table_control.Value
     if len(row_values) == 0:
         bas.MsgBox("No row selected.")
     else:
         bas.MsgBox(f"Row {table_control.ListIndex} is selected.")
   

WriteLine

HNmmm‖Add a new line at the end of a multiline text field. A newline character will be inserted when appropriate. The method returns True when successful.

D29nu‖An error is raised if the actual control is not of the type TextField or is not multiline.

FVEx2‖Syntax:

svc.WriteLine(opt line: str): bool

WADQ4‖Parameters:

jmBh7‖Line: The string to insert. Default is an empty line.

EFSA4‖Example:

3aa4B‖In Basic

      Dim oDlg As Object, oControl As Object
      Set oDlg = CreateScriptService("SFDialogs.Dialog",,, "myDialog")
      Set oControl = oDlg.Controls("thisControl")
      oControl.WriteLine("a new line")
   
BenDd‖In Python

     dlg = CreateScriptService('SFDialogs.Dialog', None, None, 'myDialog')
     ctrl = dlg.Controls('thisControl')
     ctr.WriteLine("a new line")
   
warning

uzETY‖All ScriptForge Basic routines or identifiers that are prefixed with an underscore character "_" are reserved for internal use. They are not meant be used in Basic macros or Python scripts.