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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.