Prevent control from being dragged off

S

Seth

(I had posted this over on
microsoft.public.dotnet.framework.windowsforms.designtime but it didn't see
any action, so we'll try microsoft.public.dotnet.framework.windowsforms now)

I have a custom Control that uses a custom Designer that inherits from
DocumentDesigner. The designer is specified using the DesignerAttribute on
the custom Control. On this control, I would like to prevent controls from
being dragged off of the surface. Unfortunately, there is no
OnQueryContinueDrag with which I can use to cancel the drag operation once
the control hits the edge of the surface. Does anyone have any advice on
how I might be able to accomplish this goal? Is it even possible to prevent
a control from being dragged off the parent's surface?
 
S

Stoitcho Goutsev \(100\)

Seth,

Have you tried to override CanBeParentedTo method. You can check if the new
parent is the same as the old parent and if they are not you can say that
the control coannot be parented by the new one. I haven't tried this, but
I'd expect this to do the trick.
 
S

Seth

Unfortunately, there is currently no other controls other than the main
design surface. So there is nothing else that the control could even become
a child of. Also, it appears that CanBeParentTo only gets called when a
drag begins and doesn't get called again when I hit the edge of my main
design surface control.

Thanks for the suggestion. Any hope for some more ideas? :)
 
S

Stoitcho Goutsev \(100\)

Sorry can test it right now, but How can you drag something outside the
design surface? Where it will go?
 
S

Seth

True, the control cannot be dragged completely off the design surface.
There is no where to drop it. However, my client would like the drag
process to stop when the control edge hits the edge of the design surface.
They don't want to be able to have half the control hanging off the design
surface.
 
S

Stoitcho Goutsev \(100\)

Seth,

hmm I understand now, but I don't think you have that much control over the
designer. I don't think this can be implemented. Have you seen this
implemented anywhere? Frankly I'd be surprised if you have.
 
S

Seth

Sorry for reviving this old thread, I was outta town for a couple weeks.

And to answer your question, no, I haven't seen this implemented anywhere.
Personally, I don't want to implement it, but you know how it goes, customer
is always right. :)

So if you have any other ideas, I'd still love to hear them.
 
S

Stoitcho Goutsev \(100\)

Seth,

I asked because I believe this cannot be implemented not because I question
the idea.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top