winforms - C# Drag and Drop - e.Data.GetData using a base class -


i using c# , winforms 3.5

i have list of user controls derived 1 base class. these controls can added various panels , i'm trying implement drag-drop functionality, problem i'm running in on dragdrop event.

for drageventargs e.data.getdata(typeof(baseclass)) doesn't work. wants:

e.data.getdata(typeof(derivedclass1)) e.data.getdata(typeof(derivedclass2)) etc... 

is there way can around this, or better way architect it?

you can wrap data in common class. example, assuming base class called dragdropbasecontrol

public class dragdropinfo {   public dragdropbasecontrol control { get; private set; }    public dragdropinfo(dragdropbasecontrol control)   {     this.control = control;   } } 

and drag drop can initiated following in base class

dodragdrop(new dragdropinfo(this), dragdropeffects.all); 

and can access data in drag events using following

e.data.getdata(typeof(dragdropinfo)); 

have understood requirement correctly?


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -