Author Topic: Filling an edit box from a drop list  (Read 4159 times)


  • Jr. Member
  • **
  • Posts: 68
Filling an edit box from a drop list
« on: October 01, 2013, 02:27:41 pm »
Sorry, don't work with dialog's much and it shows. I'm reading 2 text files into strings. On my dialog I want to have the user select a value from a DropList populated by the first string - this is  done and works fine. The problem I'm having is, once item 2 is selected I'd like to display item 2 from the second string in an edit box. So, since I don't explain well:

string 1 = a, b, c, d, e 
string 2 = m, n, o, p, q  (both delimited with tabs)
If the user selects 'b" from the drop down, I want the edit box to display "n"
I know the mechanics of doing the selection but I don't understand how to get it into the edit box.   

I found a script in the database that uses two item boxes - but the edit box won't accept an item insert.  Ideas VERY welcome! 


  • Full Member
  • ***
  • Posts: 184
  • WinBatch rocks, and so does Wilson WindowWare!
    • WizardWrx
Re: Filling an edit box from a drop list
« Reply #1 on: October 02, 2013, 06:05:48 am »
The edit box in your dialog box is defined by a line of code that looks like the following.
Code: [Select]
StrLenCalc02 = `65,10,210,DEFAULT,EDITBOX,InputString,""`
In the statement shown above, InputString is the name of a variable that contains the text shown in the edit control. Assign the value returned by the list box to it.
David A. Gray
You are more important than any technology.


  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: Filling an edit box from a drop list
« Reply #2 on: October 02, 2013, 08:31:10 am »
If I understand, you have two correlated lists. You would like to update an EDITBOX control dynamically when an item is selected from the DROPLISTBOX. If so you are going to need a Dynamic Dialog that uses a Dialog Callback Procedure to handle the DROPLISTBOX/Combobox event. In the event handler for the DROPLISTBOX you can get the selected item. Use ItemLocate to locate the items position in the list. Now that you have the position you can extract the item from your second list at the SAME position, then update the EDITBOX control.

Here is a code sample:

Code: Winbatch
#DefineSubroutine MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,MyDialog_ChangeInfo)
   MSG_INIT=0                    ; The one-time initialization
   MSG_BUTTONPUSHED=2            ; Pushbutton or Picturebutton
   MSG_EDITBOX=5                 ; Editbox or Multilinebox
   MSG_COMBOCHANGE=8             ; Combobox/Droplistbox
   ;Return code constants
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog
   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   switch MyDialog_Message                                  ; Switch based on Dialog Message type
      case MSG_INIT                                         ; Standard Initialization message
;         DialogProcOptions(MyDialog_Handle,MSG_TIMER,1000)
;         DialogProcOptions(MyDialog_Handle,MSG_EDITBOX,@TRUE)

        if MyDialog_Name == "PushButton_OK"                ; OK

        elseif MyDialog_Name == "PushButton_Cancel"        ; Cancel

        endif                                              ; MyDialog_Name

;     case MSG_EDITBOX                                      ; ID "EditBox_1"  ebVariable1
;        return(RET_DO_DEFAULT)

     case MSG_COMBOCHANGE                                  ; ID "DropListBox_1"  dlVariable1
        ;Get selected item
        dlItem = DialogControlGet( MyDialog_Handle, "DropListBox_1", DC_ITEMBOXSELECT, 0 )
        ;Now locate that items position in the list
        pos = ItemLocate( dlItem, string1, @tab )
        ;Grab the value at the SAME osition in the second list
        editvalue = ItemExtract( pos, string2, @tab )
        ;Now update edit box
        DialogControlSet( MyDialog_Handle, "EditBox_1", DC_EDITBOX, editvalue )

   endswitch                                                ; MyDialog_Message
#EndSubroutine                                              ; End of Dialog Callback MyDialogCallbackProc


string1 = 'a':@tab:'b':@tab:'c':@tab:'d':@tab:'e'  
string2 = 'm':@tab:'n':@tab:'o':@tab:'p':@tab:'q'

dlVariable1 = string1


MyDialogCaption=`Dual List Combo and editbox`



Deana F.
Technical Support
Wilson WindowWare Inc.


  • Jr. Member
  • **
  • Posts: 68
Re: Filling an edit box from a drop list
« Reply #3 on: October 02, 2013, 10:29:27 am »
David and Deana: thank you both! With your help it's now working - and I actually understand what we did! Thank you!