Update a dialog ListBox

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Update a dialog ListBox

Post by Jerry Thomas » Tue Sep 18, 2012 9:08 pm

I am trying to build an editor for proprietary txt files we use.
I read the file in (100-200 lines) and show it in a list box.
The user will double click the line they want to edit and it shows in an EditBox.

My problem is in 'posting' the edited data back to the List Box.

This replaces the entire entry in the List Box.
Is there a way to update just the one line?

Code: Select all

Dialog>OMXChecker
object OMXChecker: TForm
  Left = 237
  Top = 113
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'OMX Verifier'
  ClientHeight = 231
  ClientWidth = 272
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 16
    Top = 16
    Width = 81
    Height = 41
    Caption = 'Select a line.   Edit the entry.   Then click Post'
    WordWrap = True
  end
  object lbFullText: tMSListBox
    Left = 8
    Top = 72
    Width = 249
    Height = 73
    ItemHeight = 13
    TabOrder = 0
    SelectedIndex = -1
  end
  object ebNewEntry: TEdit
    Left = 10
    Top = 157
    Width = 183
    Height = 25
    TabOrder = 10
  end
  object btnPost: tMSButton
    Left = 14
    Top = 193
    Width = 91
    Height = 25
    Caption = 'Post Changes'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 11
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>OMXChecker

ADH>OMXChecker,lbFullText,OnDblClick,EditLine
ADH>OMXChecker,btnPost,OnClick,Post
SDP>OMXChecker,lbFullText,Text,abc%CRLF%123%CRLF%xyz%CRLF%PQR

Show>OMXChecker,r

SRT>EditLine
  GDP>OMXChecker,lbFullText,SelectedItems,TextLine
  SDP>OMXChecker,ebNewEntry,Text,TextLine
END>EditLine

SRT>Post
  GDP>OMXChecker,ebNewEntry,Text,NewText
  GDP>OmaxChecker,lbFullText,SelectedItems,CurrentSelection
  Let>OMXChecker.lbFullText.ItemIndex=CurrentSelection
  SDP>OMXChecker,lbFullText,Text,NewText
END>Post
Thanks,
Jerry

[email protected]

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Tue Sep 18, 2012 9:54 pm

I dropped this in the wrong bucket.
It can be moved to Technical / Scripting.
Thanks,
Jerry

[email protected]

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Oct 11, 2012 5:26 pm

Try this.

Code: Select all

Let>DisplayedText=abc%CRLF%123%CRLF%xyz%CRLF%PQR

Dialog>OMXChecker
object OMXChecker: TForm
  Left = 237
  Top = 113
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'OMX Verifier'
  ClientHeight = 231
  ClientWidth = 272
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 16
    Top = 16
    Width = 81
    Height = 41
    Caption = 'Select a line.   Edit the entry.   Then click Post'
    WordWrap = True
  end
  object lbFullText: tMSListBox
    Left = 8
    Top = 72
    Width = 249
    Height = 73
    ItemHeight = 13
    TabOrder = 0
    SelectedIndex = -1
  end
  object ebNewEntry: TEdit
    Left = 10
    Top = 157
    Width = 183
    Height = 25
    TabOrder = 10
  end
  object btnPost: tMSButton
    Left = 14
    Top = 193
    Width = 91
    Height = 25
    Caption = 'Post Changes'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 11
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>OMXChecker

ADH>OMXChecker,lbFullText,OnDblClick,EditLine
ADH>OMXChecker,btnPost,OnClick,Post
SDP>OMXChecker,lbFullText,Text,DisplayedText

Show>OMXChecker,r

SRT>EditLine
  GDP>OMXChecker,lbFullText,SelectedItems,TextLine
  SDP>OMXChecker,ebNewEntry,Text,TextLine
  GDP>OMXChecker,lbFullText,SelectedIndex,CurrentSelection
  Add>CurrentSelection,1
  Separate>DisplayedText,crlf,Line
END>EditLine

SRT>Post
  GDP>OMXChecker,ebNewEntry,Text,NewText
  Let>Line_%CurrentSelection%=NewText
  Let>DisplayedText=
  Let>kk=0
  Repeat>kk
    add>kk,1
    Let>value=Line_%kk%
    Let>DisplayedText=%DisplayedText%%Value%%crlf%
  Until>kk=Line_count
  SDP>OMXChecker,lbFullText,Text,DisplayedText
  SDP>OMXChecker,ebNewEntry,Text,
END>Post

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Thu Oct 11, 2012 7:27 pm

That works and makes sense

Thanks for the assist!
Thanks,
Jerry

[email protected]

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