Windows Develop Bookmark and Share   
 index > Windows Forms Designer > drag & drop - designer behavior
 

drag & drop - designer behavior

hi,

i have custom designer which uses panel based class as design surface. Have to troubles to drag&drop toolbox items onto surface. However, i want to customize drag and droppping in a way that i could also drop different type of data and based on those data i'd like to 1. showdifferent cursors during dragging - 2.perform custom operation on drop .

I'm struggeling with different aproaches for more than 3 days (behaviors, glyphs, overriding of everything possible), but nothing works... Only when i derive my data from Component class, i can drop it (but without ability to change cursor)...

is there anybody being able to point me to the right direction pls?

Thanks for any help
Lubos
LubosSykora  Friday, June 05, 2009 4:37 PM
oki. so for the ones having similar problem this is the solution i found...

2. create my behavior and put into stack of behaviors on the designers BehaviorService. Then in overriden OnDragEntry need to change Effect property of incoming DragEventArgs - this will allow continuation of dragging

3. needed to override OnGiveFeedback on the source control for dragging. First you need to set UseDefaultCursor to false and you can assign you own cursor to Cursor.Current

Lubos
  • Marked As Answer byLubosSykora Thursday, June 18, 2009 10:52 AM
  •  
LubosSykora  Thursday, June 18, 2009 10:52 AM
Hi - I think my information can help you:

Check out our samples at codefx:
http://cfx.codeplex.com/SourceControl/changeset/view/24764#598262

Take a look at the project: "CSWinFormDragAndDrop".

Have a nice day...

Best regards,
Fisnik
Coder24.com
Coder24.com  Friday, June 05, 2009 4:58 PM

Hi LubosSykora,

1. To change the design time cursor, you should override the OnSetCursor method of your custom design.
Like this.
protected override void OnSetCursor()
{
Cursor.Current = Cursors.Hand;
}

2. I don't know what drop did you refer to. You can try to override OnDragOver, OnDragEnter, OnDragDrop, OnDragComplete method to accomplish your task.

If I misunderstood your meaning, please feel free to tell me.

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Monday, June 08, 2009 6:16 AM
hi,

i was away during last few days so sorry for unmarking your reply as answer...

let me repeat what i need to do :
1. need to drag&drop items from toolbox containing items derieving from Control class (no problem - works fine)
2. need to support drag&drop from usual treeview so dropped item is NOT Component based (reason is to perform custom actions on drop - for simplicity just showing message box). This is most probably disabled by default 'cause when i drag such item and try to drop it on designer surface disabled cursor appears. So the question is how can i allow such action - i tried to override OnDragEnter and similar stuff but nothing works...
3. when dragging item as described in point 2. i'd like to show different cursor based on underlying control living allready in designer when i'm dragging overit (i mean when i drag&drop control as in 1., then take item from tree (2.) and when i'm over this control i wanna show special cursor).

hope this is clearer.

Thanks for any help!
Lubos
LubosSykora  Sunday, June 14, 2009 7:21 PM
oki. so for the ones having similar problem this is the solution i found...

2. create my behavior and put into stack of behaviors on the designers BehaviorService. Then in overriden OnDragEntry need to change Effect property of incoming DragEventArgs - this will allow continuation of dragging

3. needed to override OnGiveFeedback on the source control for dragging. First you need to set UseDefaultCursor to false and you can assign you own cursor to Cursor.Current

Lubos
  • Marked As Answer byLubosSykora Thursday, June 18, 2009 10:52 AM
  •  
LubosSykora  Thursday, June 18, 2009 10:52 AM

You can use google to search for other answers

Custom Search

More Threads

• Container Controls no longer accepting drag/dropped controls after a load
• Can one use an image for the actual control?
• Implement the calculator logic
• Make a Form Fill the Window at Run Time
• Designer errors
• Problem with code serialization for child controls
• Time slider Control
• Custom Control and Properties Tab
• WinForm Look and Feel
• Windows Forms Designer