Skip to main content
Mohamed Hameed21513110
Inspiring
January 26, 2022
Answered

Insert edittextbox lines to listbox items or txt file to listbox items

  • January 26, 2022
  • 2 replies
  • 299 views

Hello everyone and greetings
I have a question about List Box
I made a dialog using a text box and a list box
And I added text with lines inside the edit box
But when you add it inside the list box, the texts appear next to each other
I want to make the list box display the texts, but each separate line the same inside the edit box

Note that I will be fetching the data from a text file

I attached an explanatory text file with examples of data.. I also just wrote the code to be modified

 

This is the attached file to show the data type

https://drive.google.com/file/d/1ayJisFqELn5TKJfoQzihzBjE7Xz4Qhku/view?usp=sharing 

 

 

 

var window = new Window('dialog', "قاعدة بيانات العملاء - ابن حميدو");

var Example= window.add ('edittext {preferredSize: [650, 150] ,justify: "right", active: true,properties:{ multiline: true}}'); Example.graphics.font = "Tahoma-Bold:14";Example.enabled = true

var array = "E.Hamedoooo@gmail.com  _  01033032007  _  Hameed" + "\n" + 
"E.Hamedoooo@gmail.com  _  010050  _  Khalid Hameed" + "\n" +
"E.Hamedoooo@gmail.com  _  0120115020  _  Waled Hameed" + "\n"+
"E.Hamedoooo@gmail.com  _  01033032007  _  Hameed"+"\n"+
"E.Hamedoooo@gmail.com  _  0120115020  _  Waled Hameed"+"\n"
// or I get this items from txt file on my pc

Example.text= array

 var listBox = window.add("listbox", undefined, "" ,
            {   
            numberOfColumns: 1,   
            showHeaders: true,   
            //multiselect:true,
            columnTitles: ['Name'] ,
            columnWidths: [150],
            columnheights:[50,50],
            
        });
    
    
    listBox.graphics.font = "Tahoma-Bold:14";
  listBox.itemSize= [50,100];
  listBox.size = [650, 200];

listBox.add("item",  array );

window.center();
window.show();

 

 

 

This topic has been closed for replies.
Correct answer Kukurykus

 

array=array.split('\n'); while(array.length-1) listBox.add('item',array.shift())

 

2 replies

Kukurykus
KukurykusCorrect answer
Legend
January 26, 2022

 

array=array.split('\n'); while(array.length-1) listBox.add('item',array.shift())

 

Legend
January 26, 2022

That's not how you specify an array.