Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dragging between controls creates a shallow copy #106

Closed
matelich opened this issue Aug 28, 2014 · 2 comments
Closed

Dragging between controls creates a shallow copy #106

matelich opened this issue Aug 28, 2014 · 2 comments

Comments

@matelich
Copy link

When using two databound controls, with editable controls, if you drag an item from one to the other, a shallow copy is made, such that edits to one change the other. While many are opposed to ICloneable for not being strict enough, it is better than nothing and part of .NET.

I added ICloneable support in matelich@564f258 but didn't expand it with a sample, so I haven't submitted a pull request.

Obviously I could fix it with my own drop handler, but it seems like the proper behavior for the default drop handler to me.

@punker76
Copy link
Owner

@matelich i think it's ok to do this. i would make this

        var sourceList = GetList(dropInfo.DragInfo.SourceCollection);
        var clones = sourceList.OfType<ICloneable>();
        if (clones.Any()) {
          data = clones.Select(c => c.Clone());
        }

instead this

        var sourceList = GetList(dropInfo.DragInfo.SourceCollection);
        if (sourceList[0] is ICloneable) {
          var clones = new ArrayList();
          foreach (ICloneable o in data) {
            clones.Add(o.Clone());
          }
          data = clones;
        }

@matelich
Copy link
Author

Great alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants