?
Solved

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

Posted on 2004-04-24
10
Medium Priority
?
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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