Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Dec 18, 2017 1:43 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: copy item on listbox
PostPosted: Tue Feb 26, 2013 2:40 am 
Offline

Joined: Tue Aug 29, 2006 4:04 am
Posts: 513
Location: Indonesia
Hi,

I have 2 listboxes with 2 columns

the item on listbox1 :

col1 col2
001 apple
002 orange
003 amngo

how to copy the row to the listbox2 by typing the text which is match with the code.
for example If I type 001 on a textfield, it should add row to the listbox2 with the correct item. The result on listbox2 should be 001(row,column0) and apple (row,column1)

any helps.?


thanks
Regards,
Rivo


Top
 Profile  
Reply with quote  
 Post subject: Re: copy item on listbox
PostPosted: Mon Mar 04, 2013 4:56 pm 
Offline
Site Admin
User avatar

Joined: Fri Sep 30, 2005 9:35 am
Posts: 987
Location: South Portland, Maine
Sounds like you just need some simple looping. Loop through Listbox1 to find the row you want to copy. Use the Cell method to check the column for the value you are searching for. Once you have found it, use the ListBox2.AddRow method to copy the row to ListBox1 (use the ListBox1.Cell method to get the values to copy). Then you can delete the row from ListBox1 using the RemoveRow method.

_________________
Paul Lefebvre
Developer Evangelist
Xojo, Inc.


Top
 Profile  
Reply with quote  
 Post subject: Re: copy item on listbox
PostPosted: Mon Mar 04, 2013 7:00 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
dim i as integer
dim s as string

s = txt_copy.Text.trim // I use trim to make sure extra spaces don't mess up things

if listbox1.ListCount = 0 then exit
for i = 0 to listbox1.ListCount -1
if listbox1.cell(i,0).Trim = s then
listbox2.AddRow listbox1.cell(i,0), listbox1.Cell(i,1)
exit
end if
next i

_________________
Future RS guru.
Ride the world!


Top
 Profile  
Reply with quote  
 Post subject: Re: copy item on listbox
PostPosted: Mon Mar 04, 2013 11:12 pm 
Offline

Joined: Tue Aug 29, 2006 4:04 am
Posts: 513
Location: Indonesia
Thankss

its worked nice.. ;)


regards,
Rivo


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

All times are UTC - 5 hours


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

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