Adding Data in List Box and Combo Box in Dialog

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
winstein
Pro Scripter
Posts: 84
Joined: Mon Nov 26, 2012 3:44 pm

Adding Data in List Box and Combo Box in Dialog

Post by winstein » Fri Nov 01, 2013 10:09 am

Currently, I want to add a list of data in a Dialog Box's List Box and Combo Box, but the thing is, I want to make it interactive. So now I have a couple of things I want to do:

1) Make a list of data in the List Box or Combo Box. It's not just one line of text, but a list of them.
2) Each line of data will influence another text box in the Dialog Box. That's because I want it to be able to be edited.

How am I able to achieve both of the above?

Thanks for reading.

EDIT: Sorry I didn't make one thing clear, since I was in a hurry when I put this message. That one thing I want is to be able to read an array, and then add elements of that array into the List Box/Combo Box.
Last edited by winstein on Mon Nov 04, 2013 4:04 am, edited 1 time in total.
PPQ

User avatar
PepsiHog
Automation Wizard
Posts: 512
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Post by PepsiHog » Mon Nov 04, 2013 1:10 am

Hello winstein,

See if this example will help you.

Code: Select all



Dialog>Dialog1
object Dialog1: TForm
  Left = 251
  Top = 104
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Challenge 8'
  ClientHeight = 234
  ClientWidth = 529
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poDesktopCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 256
    Top = 64
    Width = 119
    Height = 16
    Caption = 'Selections Editor'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -13
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Label2: TLabel
    Left = 128
    Top = 200
    Width = 361
    Height = 26
    Caption = 
      'Both MSListBox and MSComboBox have their selection separated by ' +
      'CRLF. '#13#10' Press enter in the Selections Editor to create more sel' +
      'ections.'
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clRed
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentColor = False
    ParentFont = False
  end
  object MSComboBox1: tMSComboBox
    Left = 24
    Top = 16
    Width = 392
    Height = 21
    ItemHeight = 13
    TabOrder = 0
  end
  object MSListBox1: tMSListBox
    Left = 24
    Top = 56
    Width = 170
    Height = 137
    ItemHeight = 13
    TabOrder = 2
    SelectedIndex = -1
  end
  object MSButton1: tMSButton
    Left = 424
    Top = 80
    Width = 75
    Height = 25
    Caption = 'Update Lists'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 3
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 424
    Top = 168
    Width = 75
    Height = 25
    Caption = 'Cancel'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 4
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSMemo1: tMSMemo
    Left = 224
    Top = 80
    Width = 185
    Height = 112
    Hint = 'Type Selections To Be Added To'#13#10'Both MSListBox And ComboBox.'
    TabOrder = 1
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,DoUpdateList
AddDialogHandler>Dialog1,MSButton2,OnClick,DoExit

SetDialogObjectFocus>Dialog1,MSMemo1

Show>Dialog1,r

srt>DoUpdateList
GetDialogProperty>Dialog1,MSMemo1,Text,Selections

SetDialogProperty>Dialog1,MSComboBox1,ListText,%Selections%
SetDialogProperty>Dialog1,MSListBox1,Text,%Selections%
END>DoUpdateList
PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

winstein
Pro Scripter
Posts: 84
Joined: Mon Nov 26, 2012 3:44 pm

Post by winstein » Mon Nov 04, 2013 4:01 am

Thanks for your effort. Perhaps there could be something I could get from it.

You likely didn't know this, but I received some help from another person in a private message regarding this problem before you sent this.

I didn't ask this, likely because I forgot, but do any of you know how to implement arrays into a list box or combo box?

Thanks for your help, in any case.

EDIT: By the way, where is the DoExit Subroutine?
PPQ

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Nov 04, 2013 12:55 pm

winstein wrote: EDIT: By the way, where is the DoExit Subroutine?
Add this to the script:

Code: Select all

SRT>DoExit
  Exit>1
END>DoExit

User avatar
PepsiHog
Automation Wizard
Posts: 512
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Post by PepsiHog » Mon Nov 04, 2013 1:23 pm

@ winstein,

Rain has it. Sorry, must have forgotten to write it. If the array contains the data you want to place in the ListBox just specify the array with sdp>

SetDialogProperty>Dialog1,MSListBox1,Text,%ArrayName%

SetDialogProperty>Dialog1,MSComboBox1,ListText,%ArrayName%

@ Rain,

Thanks, Rain.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

winstein
Pro Scripter
Posts: 84
Joined: Mon Nov 26, 2012 3:44 pm

Post by winstein » Wed Nov 06, 2013 3:05 am

PepsiHog wrote:@ winstein,

Rain has it. Sorry, must have forgotten to write it. If the array contains the data you want to place in the ListBox just specify the array with sdp>

SetDialogProperty>Dialog1,MSListBox1,Text,%ArrayName%

SetDialogProperty>Dialog1,MSComboBox1,ListText,%ArrayName%
When I did what you do, the List Box and Combo Box will show on their lists instead of the full list.

How did you do it?
PPQ

User avatar
PepsiHog
Automation Wizard
Posts: 512
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Post by PepsiHog » Sat Nov 09, 2013 7:29 pm

@ winstein,

I've been thinking how to answer, "How did you do it?" and there are no tricks. Are you surrounding your arrays with the percent(%) symbol?

If the example script worked for you, then there is something missing within your script. The only way I could help you with that is if you post the script.

PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts