How to set drag&drop image?

  • Thread starter Thread starter Jeff0803
  • Start date Start date
J

Jeff0803

Guest
On the WinForm's TabControl, there are several tabs which have image of it's own.

I made codes for drag&drop except drag&drop image.

If drag a tabpage, then the image of the tabpage should be displayed when dragged.

How could I make it?

Here is the codes I made for drag and drop.

private void tabControlDevices_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
m_tabpagepressed = true;
}
}

private void tabControlDevices_MouseMove(object sender, MouseEventArgs e)
{
if (m_tabpagepressed)
{
TabControl tab = sender as TabControl;
tabControlDevices.DoDragDrop(/*this.imageList1.Images[tab.SelectedTab.Text]*/tabControlDevices.SelectedIndex.ToString(), DragDropEffects.Copy | DragDropEffects.Move);
m_tabpagepressed = false;
}
}
//drag & drop
private void labelRecycleBin_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}

//drag & drop
private void labelRecycleBin_DragDrop(object sender, DragEventArgs e)
{
MessageBox.Show(e.Data.GetData(DataFormats.Text).ToString());
}

Continue reading...
 
Back
Top