Groups | Blog | Home
all groups > dotnet windows forms designtime > october 2004 >

dotnet windows forms designtime : Need an event for when the user drags a component on


Marina
10/11/2004 3:09:45 PM
Hi,

I need an event that fires ONLY when the user has JUST dragged a component
on.
I tried creating my own ComponentDesigner class to deal with some events.

I tried handling the ComponentAdded event. ComponentAdded fires whenever
the project is loaded and the form designer is loaded.

The ComponentAdding event does not run unless at least 1 of the object is
already on the form. And it always runs for all the previous instances of
the object - not for the current one (Initialize method is called after
ComponentAdding is called).

Basically, if the object just got added to the form (i.e. user just dragged
it on), I want to create another object to go along with it.

Alternatively, I could deal with checking if a particular property is set to
perform this action. Problem is, that ComponentAdded is run before the
property sets from the previous design session are run - so the property is
never set at the time this event runs.

Any solutions?

Marina
10/11/2004 3:46:44 PM
Found that if I get the IDesignerHost service, I could check its Loading
property to see if the designer was loading. If it is not, then I know the
control was just added. If it is, then I know the designer is just loading,
so no need to do anything.

[quoted text, click to view]

Joey Callisay
10/12/2004 9:32:17 AM
I can sense that you are creating a custom container control, aren't you?
If you are, then there is a CanParent method to validate the controls added
to your container control...

here is another good link on designers:
http://www.divil.co.uk/net/articles/designers/collectioncontrols.asp

[quoted text, click to view]

Marina
10/15/2004 10:59:56 AM
No, I actually wasn't. I don't think CanParent has anything to do with what
information I needed. The Loading property does the trick though.

[quoted text, click to view]

AddThis Social Bookmark Button