Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

additem in listbox 5

Status
Not open for further replies.

R17

Programmer
Jan 20, 2003
267
PH

hello,

i use This.list1.AddItem(empno) to add items to my list.

but how to add at least 3 columns using the AddItem?

i want to be able to add fields (empno, lastname, firstname, mid) to my list. how do i do that?

help pls?

 
Hi R17,

You need to use AddItem to add the first column, and AddListItem to add the other columns.

AddListItem takes three parameters:
- The text to be added
- The list item ID. This is a unique number which identifies the item; it is essentially a sequence number.
- The column number.

As an example, assume that empno, lastname and firstname are all fields in your employee table. Here's the code:

SELECT Employee
lnI = 1 && this is the list item ID
SCAN
THIS.AddItem(Empno) && 1st col.
THIS.AddListItem(lastname,lnI,2) && 2nd col
THIS.AddListItem(firstname,lnI,3) && 3rd col
lnI = lnI + 1
ENDSCAN

You should also use the ColumnWidths property to make sure that each column in an appropriate width.

By the way, have you by any chance been on one of my courses? The reason I ask is that your example is exactly the same as one that I use to demonstrate listboxes?

Let me know if any further questions.

Mike

Mike Lewis
Edinburgh, Scotland
 
Mike,

Your post just saved me a lot of time and hassle...thanks and here is a well deserved star.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
MIKE SAME SENTIMENTS AS SLIGHTHAZE.


I have been concatenating columns values to one string and using only .additems.


One star for you Sir

 
Thank you both for those stars. When I first tried to do this, I found the Help totally misleading. It took a lot of trial and error to figure it out, but once you know how, it's quite straightforward.

Mike


Mike Lewis
Edinburgh, Scotland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top