how can i add drag and drop capability of a custom usercontrol from 2 flowlayoutpanels?
Usercontrol keeps being null on the following line of code below
private void flowLayoutPanel1_DragDrop(object sender, DragEventArgs e)
{
UserControl userControl = e.Data.GetData(typeof(UserControl)) as UserControl;
The problem with what you are doing is that to extract the data that is stored inside the drag, you have to specify the exact type.
What you have to do is create a wrapper and use that for your drag-and-drop code.
And your code now becomes
And trying not to sound too preachy, but you should check if the data exists in the form you want first.
e.Data.GetDataPresent(typeof(ControlWrapper))will tell you if it is that format.