Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 11:44 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Populating a listbox
PostPosted: September 23rd, 2006, 9:16 am 
Offline

Joined: April 11th, 2005, 2:31 pm
Posts: 122
Location: Edinburgh
I have a MySQL DB from which I want to extract information and display in a listbox (first name and last name). I assume that I am going to have to use a combination of SetSelection and ReplaceSelection as per textbox, but, I cannot see how to apply these to a listbox :( How do I populate the listbox using a script and variables extracted from the DB?

Another quick one - how do you add a line feed or carriage return (ASCII chr(13)) to a line of text to force a new line?

Cheers

_________________
Windows 7 Ultimate (32 bit)
Opus Pro 6.4, Opus 7
Dual Core Athlon 64 4000+
4 gb Ram


Top
 Profile  
 
 Post subject:
PostPosted: September 24th, 2006, 8:08 am 
Offline

Joined: April 1st, 2005, 6:59 pm
Posts: 98
Location: Maastricht, The Netherlands
Opus: V7
OS: Mac OS X 10.7.2 | Windows 8 Dev
System: i5 2.7 | 8G Ram | 1 T HD
Hi,

Try this one, replace the name "Listbox 1" with your listbox.

Code:
var db = new Database("FILEDSN=artikelenontwerp.dsn");
var records = null;
var num_records = 0;

//////////////////////////////////////////////////////////////////////////////
//
// NOTE: Start_Record_Num is the record number for the first of the 5 records
//       and it is a Page Variable
//

function SearchDB()
{
   var sql = "SELECT * FROM Customers WHERE LastNAme = '" + zoek + "' ORDER BY LastNAme;";
   // Debug.trace(sql+"\n");
   records = db.ExecuteSQL(sql);
   num_records = records.GetNumberOfRecords();
   numberrecords = num_records;
   ShowRecords();
}

function ShowRecords()
{
   if (records == null) {
      return;  // need to call Search First to get records
   }
   var list_box = Listbox_1;
   list_box.SetSelection(0, -1);   // Select all the old text
   list_box.ReplaceSelection("");   // Remove all the old text
   
   if (records.FirstRecord()) {
      list_box.ReplaceSelection(records.FirstNamet+"\t "+records.LastName);
      records.NextRecord();
      for (i=1; i<num_records; i++) {
         list_box.ReplaceSelection("\n"+records.LastName+"\t "+records.FirstName);
         records.NextRecord();
      }
   }
}




Regards,

Ronnie Dackus


Last edited by Ronnie Dackus on September 25th, 2006, 7:37 am, edited 1 time in total.

Top
 Profile Visit website  
 
 Post subject:
PostPosted: September 24th, 2006, 9:18 pm 
Offline

Joined: April 11th, 2005, 2:31 pm
Posts: 122
Location: Edinburgh
Cheers Ronnie - just what I was looking for :D

_________________
Windows 7 Ultimate (32 bit)
Opus Pro 6.4, Opus 7
Dual Core Athlon 64 4000+
4 gb Ram


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 36 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group