TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
rulec444
NA
81
0
Adding and removing items of databound listbox
Jul 20 2004 12:41 PM
I have a window forms application with two listboxes and 2 buttons. lbxAllItems, on the Right, is bound to a datatable (from a dataset from the database). When the user selects and item in lbxAllItems and clicks on btnAdd, I would like to remove that item from lbxAllItems and add it to lbxSelection. Conversely, when the user selects an item in lbxSelection and clicks on btnRemove, I would like to remove that item from lbxSelection and add it to lbxAllItems. This is what I've tried and its not working: private void btnAdd_Click(object sender, System.EventArgs e) { lbxSelection.Items.Add(((DataRowView)lbxAllItems.SelectedItem)["Items"]).ToString(); lbxAllItems.Items.Remove(((DataRowView)lbxAllItems.SelectedItem)["Items"]); } private void btnRemove_Click(object sender, System.EventArgs e) { lbxAllItems.Items.Add(lbxSelection.SelectedItem.ToString()); lbxSelection.Items.Remove(lbxSelection.SelectedItem.ToString()); } However, this is not working. When I clicking btnAdd, an item is added, but the item from the lbxAllItems is not removed. And when I click on btnRemove, the item IS removed from lbxSelection, but not added to the lbxAllItems. Is this an issue because lbxAllItems is bound? Thanks.
Reply
Answers (
2
)
datagrid update
Textbox Shortuts Keys