DragEnter Event

DragEnter is the event that fires when an object is dragged into the control's bounds. Here is an example code to show how DragEnter event works.


private void TextBoxLowerRight_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
// Check to be sure that the drag content is the correct type for this
// control. if not, reject the drop.

if (e.Data.GetDataPresent(DataFormats.Text))
{
// if the Ctrl key was pressed during the drag operation then perform
// a Copy. if not, perform a Move.
if ((e.KeyState & CtrlMask) == CtrlMask)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.Move;
}
}
else
{
e.Effect = DragDropEffects.None;
}
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: