Purpose
Use the standard SAP GUI text edit control to display and enter text

The GuiXT Textbox command can be used for displaying and entering text. In some cases it makes sense to use the SAP GUI edit control instead, since it offers additional functions: search and replace, file drag&drop, protecting a part of the text against changes.
Solution
Use a Control statement with progID="sapgui.texteditctrl". Call up the methods of the text edit control with CallVB or CallJS.


Example
We display the material sales text; the text language can be selected by the user:

 

// text control
Control
    (4,2)       (17,70.2) _
 
progID="sapgui.texteditctrl"    _
  initFlag="editcontrol.init" _
  name="editcontrol"

// initialize textcontrol
if V[editcontrol.init]
  CallVB utilities.textedit.init "&V[editcontrol]"
endif

....

// set text into text edit control
CallVB utilities.textedit.settext "&V[editcontrol]" "mytext"

See below for the complete GuiXT Script.

The VB.NET coding is as follows: 

Public Class textedit
    Private guixt As New guinet.guixt


    Public Sub init(tc As TEXTEDITLib.ITextEditCtrl)

        ' no status bar
        tc.StatusBarVisible = False

    End Sub

    Public Sub settext(tc As TEXTEDITLib.ITextEditCtrl, _
                                           textname As String)

        tc.Text = guixt.GetText(textname)

    End Sub
End Class


In your VB.NET project you need the correct reference to the edit control :


This allows you to display all properties and methods in Visual Studio via context sensitive help:

You may also have a look at the SAP system which defines an ABAP OO wrapper around the text edit control:

 


GuiXT Script
 

Offset (4,10)

// material number
InputField (2,3)       "Material"       (2,15)      size=18  _ 
 
name="matnr" techName="MARA-MATNR"  -upperCase

// language selection
Set text[languages] "=Select a language;E=English;F=French;D=German;I=Italian"

 // text control
Control    (4,2)       (17,70.2) _
 
progID="sapgui.texteditctrl"    _
  initFlag="editcontrol.init" _
  name="editcontrol"

// initialize textcontrol
if V[editcontrol.init]
  CallVB utilities.textedit.init "&V[editcontrol]"
endif

 // default language code
if not V[langu]
  Set V[langu] "&V[_language]"
endif

DropDownList     (18.2,2.6) "languages" width=20  _
 
refer="V[langu]" -noSort process="return.txt"

 // read sales long text
if not V[matnr=&V[prev_matnr]]

 
 
// convert material number
  Call /GUIXT/EXT2INT _
    in.DOMNAME="MATNR" _
    
in.EXTVALUE="&V[matnr]" _
    
out.INTVALUE="intmatnr"

    // Read texts
   
Call "BAPI_MATERIAL_GET_ALL" _
      in.MATERIAL="&V[intmatnr]" _
      in.SALESORG="1000" _
      in.DISTR_CHAN="10" _
      table.MATERIALLONGTEXT="txt"

endif

// matnr or language  changed?
If not V[matnr=&V[prev_matnr]] or not V[langu=&V[prev_langu]]
  clear text[mytext]
  Set V[k] 1

  label nextline
  CopyText fromText="txt" toString="s" line="&V[k]"
  if Q[ok]
    Set V[TDOBJECT]    "&V[s](BAPI_MLTX_GA-APPLOBJECT)"
   
Set V[TDID]        "&V[s](BAPI_MLTX_GA-text_ID)" 
   
Set V[TDSPRAS]     "&V[s](BAPI_MLTX_GA-LANGU)" 
   
Set V[TDFORMAT]    "&V[s](BAPI_MLTX_GA-FORMAT_COL)"
   
Set V[TDLINE]        "&V[s](BAPI_MLTX_GA-text_LINE)"

    if V[TDOBJECT=MVKE] and V[TDID=0001]  and  V[TDSPRAS=&V[langu]]
       if V[TDFORMAT=*] or  V[TDFORMAT=/]
        CopyText fromString="TDLINE"   toText="mytext" -appendLine
      else
        CopyText fromString="TDLINE"   toText="mytext" -append
      endif
    endif

    Set V[k] &V[k] + 1
    goto nextline

  endif

  // set text into text edit control
  CallVB utilities.textedit.settext "&V[editcontrol]" "mytext"
endif

 

// save entered values
Set V[prev_matnr] "&V[matnr]"
Set V[prev_langu] "&V[langu]"

 

Components
InputAssistant + Controls