Solved

2 List Boxes - Select item in one to then appear in listbox2

Posted on 2004-04-24
10
326 Views
Last Modified: 2010-05-18
I am trying to write the code to be able to select an item in one
listbox and then have that item appear in a second list box. I do
not want more than 20 items to be selected from first listbox.
0
Comment
Question by:James_Napier
  • 5
  • 3
  • 2
10 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 10908167
Hi
1. Do You want to select max 20 items at once or one at a time?
2. When do You want the selected item appear in the second listbox?
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10908184
for I:= 0 to ListBox1.Count - 1 do
  if ListBox1.Selected[I] then
    ListBox2.Items.Add(listBox1.Items[I]);


Shane
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 500 total points
ID: 10908220
procedure TForm1.Button1Click(Sender: TObject);
var
 I: Integer;
begin
 for I:= 0 to ListBox1.Count - 1 do
  if ListBox1.Selected[I] then
    ListBox2.Items.Add(listBox1.Items[I]);
end;

procedure TForm1.ListBox1Click(Sender: TObject);
var
 I: Integer;
begin
 I:= listbox1.ItemIndex;
 if listbox1.SelCount > 20 then
  ListBox1.Selected[I]:= False;
end;
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:James_Napier
ID: 10908558
Many thanks - would it make any difference if I
am using a DBListbox as listbox1?
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10908566
Nope, I dont believe so, it has the same properties..... Although, i didn't test it... im sure it wont matter

Shane
0
 
LVL 17

Expert Comment

by:mokule
ID: 10908574
With DBListbox it absolutly don't work.
0
 

Author Comment

by:James_Napier
ID: 10908588
Agree - it doesn't seem to work. What would work in this case? I am transferring data
form a dbcontrolgrid into dblistbox1 and now need to allow users to select items in
dblistbox1(maximum total selection not greater than 20) and have then transfered to
a second listbox.
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10908610
Sorry, hes right, there is no Multiselect ---- <SMILE>

Shane
0
 
LVL 17

Expert Comment

by:mokule
ID: 10908665
Not quite.
Multiselect can be set at runtime.
What I mean was the trouble with unwanted change of data in database.
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10908712
Right,  multiselect can be used at runtime, if you use the Selection array
however, you can't physically select from the OnClick event....and show the highlighted selections

designed for one selection .....


Shane
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now