Highlighted
Absent Member.
Absent Member.
2523 views

[archive] AutoComplete TextBox

[Migrated content. Thread originally posted on 22 June 2009]

I would like to be able to put a TextBox/Entry-Field with autocomplete on a form. I thought I would be able to do it by placing the .NET TextBox control on my form, but although I can get the TextBox to appear, and I set the properties to make it autocomplete, it doesn't seem to be working. Has anyone successfully done something like this? I created a .NET DEF file using netdefgen and System.Windows.Forms.dll


SCREEN SECTION.
          03 TEXTBOX-HANDLE, "@System.Windows.Forms"
                NAMESPACE is "System.Windows.Forms",
                CLASS-NAME is "TextBox",
                FILE-PATH is "bin\forms.xml"
                LINE 49.5
                COL 10
                .

PROGRAMMING SECTION.
           MODIFY TEXTBOX-HANDLE "set_AutoCompleteMode"(
              "@AutoCompleteMode_SuggestAppend")
              GIVING RTN-CODE.
           MODIFY TEXTBOX-HANDLE "set_AutoCompleteSource"(
              "@AutoCompleteSource_FileSystem")
              GIVING RTN-CODE.



-Chris
0 Likes
8 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] AutoComplete TextBox

Making the reservation that I have not seen the .def file here, my bet is that AutoCompleteSource_FileSystem is an enumerate member, e.g. it is a numeric constant, not a string (which you indicate by surrounding it with double qoutes).

Check the def file, and see if this tag (AutoCompleteSource_FileSystem) is followed by a number. If so, remove the double quotes and it might work.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] AutoComplete TextBox

Gisle;
Those are both parts of their respective enumerations, and I tried them both without quotes, and with the actual value (1, in the case of System.Windows.Forms.AutoCompleteSource.FileSystem), and I still haven't had any luck. I added a TextBox to a form in VB, and specified only the following:


Me.TextBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend
Me.TextBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.FileSystem
Me.TextBox1.Size = New System.Drawing.Size(100, 20)


The autocomplete worked as expected. The part that I find a bit perplexing is that I do actually get the TextBox on the form (under AcuCOBOL), it just behaves as though I had not set the autocomplete properties.

-Chris
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] AutoComplete TextBox

Would simplify things if you could post a small example (just the cobol source and the def file please).
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] AutoComplete TextBox

I attached a program that displays a window with the control on it, and the DEF file. The copybooks that I used are all the standard ones that comes with the runtime (in the AcuGT\sample\def directory).

Thanks,
-Chris
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] AutoComplete TextBox

I will take a look at it when I find time.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] AutoComplete TextBox

The following code will autocomplete filepaths when run.

Make sure you have AcuToNet and Marshal properly registered, compile and run.

Type C: in the form entry, allow the system to catch up, and a combo will pop up, listing directories and files in C:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TxForm.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SPECIAL-NAMES.
           COPY "FORMS.DEF".
           .
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       77  CNTL-FONT                USAGE HANDLE OF FONT SMALL-FONT.
       77  ERROR-SOURCE             PIC X(30).
       77  ERROR-DESCRIPTION        PIC X(50).
       77  ERROR-HELP-FILE          PIC X(200).
       77  ERROR-HELP-CONTEXT       USAGE UNSIGNED-LONG.
       COPY "ACTIVEX.DEF".
       SCREEN SECTION.
       01  MAIN-SCREEN.
           03 hTextBox              "@System.Windows.Forms"
              NAMESPACE             "System.Windows.Forms"
              CLASS-NAME            "TextBox"
              LINE                  2
              COL                   2.
           03 PUSH-BUTTON           "Exit"
              EXCEPTION-VALUE       32
              COL                   + 5.
       PROCEDURE DIVISION.
       DECLARATIVES.
       OBJECT-EXCEPTION             SECTION.
           USE     AFTER            EXCEPTION ON OBJECT.
       OBJECT-EXCEPTION-HANDLER.
           CALL    "C$EXCEPINFO"    USING
                   ERROR-INFO
                   ERROR-SOURCE
                   ERROR-DESCRIPTION
                   ERROR-HELP-FILE
                   ERROR-HELP-CONTEXT.
           DISPLAY MESSAGE          BOX
                   ERROR-DESCRIPTION
                   TITLE            "Object Error!"
           GOBACK
       END DECLARATIVES.
       MAIN SECTION.
       MAIN-001.
           DISPLAY STANDARD         GRAPHICAL WINDOW
                   TITLE            "Windows form Autocomplete demo"
                   FONT             CNTL-FONT
                   BACKGROUND-LOW
                   SIZE             80
                   LINES            25.
           DISPLAY MAIN-SCREEN
           MODIFY  hTextBox         "set_AutoCompleteMode"(
                   @AutoCompleteMode_SuggestAppend).
           MODIFY  hTextBox         "set_AutoCompleteSource"(
                   @AutoCompleteSource_FileSystem).
           ACCEPT  MAIN-SCREEN.
           DESTROY hTextBox.
           STOP RUN.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] AutoComplete TextBox

Gisle;
Thank you! I just realized that the only problem with the code I had written in the first place is that I was doing the "MODIFY" before I displayed the screen. I changed my original program to do the MODIFY after the screen had been displayed, and it worked. Now to figure out how to get it to auto-complete using my own custom list.

Thanks!
-Chris
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] AutoComplete TextBox

While the compiler does allow it, and your application will execute, setting properties to a control before it is instantiated will have no effect.

Obviously, I should have caught this too, but nobody's perfect 🙂
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.