我想将某个控件的另一个副本拖放到另一个窗体时。我的代码导致移动整个控件。是否有办法一次显示它们中的两个,因为我希望它们具有相同的引用,因为源每秒更新一次值。将控件从一个窗体拖放到另一个窗体导致移动控件
这里是我的代码
public partial class DragDropForm : Form
{
public DragDropForm()
{
InitializeComponent();
}
private void tableLayoutPanel1_DragEnter(object sender, DragEventArgs e)
{
object data = e.Data.GetData(e.Data.GetFormats()[0]);
if (data is GaugeContainer)
{
GaugeContainer gauge = data as GaugeContainer;
tableLayoutPanel1.Controls.Add(gauge);
}
else if (data is DataGridView)
{
DataGridView table = data as DataGridView;
tableLayoutPanel1.Controls.Add(table);
}
}
private void tableLayoutPanel1_DragDrop(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy ;
}
}
// IN THE SOURCE FORM !!!!
private void topCompaniesGridView_MouseDown(object sender, MouseEventArgs e)
{
this.DoDragDrop(this.topCompaniesGridView, DragDropEffects.Copy);
}