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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass entries between listboxes

Status
Not open for further replies.

Henning

Programmer
Mar 18, 2002
10
0
0
DE
i want to have two listboxes, one containing data. with an "add" button i want the marked entry to be moved to the other listbox!?! is that possible? thank you for your help in advance.
henning
 
Try that:
---------------------
set list1 {first second last}
set list2 {}
pack [listbox .lb1 -listvar ::list1]
pack [listbox .lb2 -listvar ::list2]
pack [button .btn -text add -command add]
proc add {} {
foreach index [.lb1 curselection] {
set item [lindex $::list1 $index]
.lb2 insert end $item
.lb1 delete $index
}
}
---------------------

The ::list global variables handles the contain of the listbox.
Manipulating these variables is manipulating the list boxes.
For each value in the .lb1 selection the add proc adds the item to the .lb2 listbox, deleting the item from the .lb1 listbox.

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top