Simon,
I think you can probably use the .Equal() method to be sure you're dragging
into a different TaskBox object. So, something like this in your DragEnter:
object o = e.Data.GetData(DataFormats.Serializable);
TaskBox tb = (TaskBox)sender;
if (o is TaskBox && !o.Equals(tb))
{
// they're not equal, do your thing
}
~~Bonnie
> Hi ppl,
>
[quoted text clipped - 74 lines]
>
> <Id>SrIET38ZtUuYEqd5pn3s1g==</Id>
simonrigby_uk@hotmail.com - 14 Apr 2005 17:11 GMT
> Simon,
>
[quoted text clipped - 14 lines]
> >
> > I have a situation where a user can add a user control to another control (like a scratchpad) at runtime. I've done this by way of a
context menu. The user selects to add a new item from the context menu
and then clicks on the scratchpad where they want to create the new
control.
> > All works fine.
> >
> > I want a user to be able to establish a relationship between any two controls by dragging one instance to another.
> >
> > The problem is that in OnDragEnter I am looking to see if the control being dragged is of the right type. Of course this means that
as soon as I mouse down on the source control, the event fires and
thinks I'm dragging it to itself. What I really need is someway of
quizzing the source control, to make sure it isn't the same instance as
the destinataion.
> > Some code attached.
> >
[quoted text clipped - 47 lines]
> >
> > So in effect when I drag any instance to another instance the source changes its text to "Copying". I need this event to fire only
when the source is dragged to another instance.
> > I tried modiying the if statement in TaskBox_DragEnter() to
> > if (!e.Data.Equals(sender) && e.Data.GetDataPresent(typeof(TaskBox)))
[quoted text clipped - 12 lines]
> >
> > <Id>SrIET38ZtUuYEqd5pn3s1g==</Id>
simonrigby_uk@hotmail.com - 14 Apr 2005 17:12 GMT
Thanks that worked.
> Simon,
>
[quoted text clipped - 14 lines]
> >
> > I have a situation where a user can add a user control to another control (like a scratchpad) at runtime. I've done this by way of a
context menu. The user selects to add a new item from the context menu
and then clicks on the scratchpad where they want to create the new
control.
> > All works fine.
> >
> > I want a user to be able to establish a relationship between any two controls by dragging one instance to another.
> >
> > The problem is that in OnDragEnter I am looking to see if the control being dragged is of the right type. Of course this means that
as soon as I mouse down on the source control, the event fires and
thinks I'm dragging it to itself. What I really need is someway of
quizzing the source control, to make sure it isn't the same instance as
the destinataion.
> > Some code attached.
> >
[quoted text clipped - 47 lines]
> >
> > So in effect when I drag any instance to another instance the source changes its text to "Copying". I need this event to fire only
when the source is dragged to another instance.
> > I tried modiying the if statement in TaskBox_DragEnter() to
> > if (!e.Data.Equals(sender) && e.Data.GetDataPresent(typeof(TaskBox)))
[quoted text clipped - 12 lines]
> >
> > <Id>SrIET38ZtUuYEqd5pn3s1g==</Id>