Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.

Newbie question here.

I have a bunch of listboxes bound each one to a different ObservableCollection created inside a class.

The names of the listboxes matches the names of the ObservableCollections.

Dropping an item inside the different listboxes gives you the name of the Listbox where it has dropped (this code is in a different class where the listbox was created)

private void ListBox_PreviewDrop(object sender, DragEventArgs e)
    {
        var source = e.Source as ListBox;
        string goesto = source.Name.ToString();
        
}


My question:

How could i add an item to that ListBox named exactly as the e.Source.Name value???

Hope someone understand the question... it is just a "After retrieving the name of the ListBox where the drop was done, add an item to that ListBox" Something like

listbox(goesto).Items.Add(SomeItem);


Thank you!
Posted
Updated 19-Jul-15 13:07pm
v3

1 solution

C#
var source = e.Source as ListBox;
if(source != null)
 source.Items.Add(source.Name.ToString());
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900