all groups > dotnet windows forms designtime > january 2007 >
You're in the

dotnet windows forms designtime

group:

How to know when a component is draged on a form?


How to know when a component is draged on a form? Mario Vázquez
1/17/2007 3:56:41 PM
dotnet windows forms designtime:
Hi all,
I'm trying to build a component which takes advantage of other components.
So, when this new component is draged to the form, I would like to insert
other components on the designer and relate them. But only the first time
the component is inserted! to avoid inserting components each time de form
is loaded in the IDE.
How can I hook the very first time a component is draged on a windows form?

Thanks for attention,
Mario Vazquez

Re: How to know when a component is draged on a form? Carlos J. Quintero [VB MVP]
1/18/2007 11:24:26 AM
Hi,

I was also interested in that problem and I found that the ComponentAdded
event does not provide that info. There are several cases:

- A component added from the toolbox
- A paste operation
- An undo operation (that places a control that was deleted)
- ...

Maybe a control designer has other hooks but the ComponentAdded event that
add-ins can use doesn't.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com


"Mario Vázquez" <alguien@microsoft.com> escribió en el mensaje
news:%23DZ1kekOHHA.4604@TK2MSFTNGP06.phx.gbl...
[quoted text, click to view]

Re: How to know when a component is draged on a form? Mario Vázquez
1/18/2007 3:57:00 PM
Hi Carlos,

Thanks for the tip.
Well, it seems not an easy issue.
I've just found an interface (framework 2.0) that may help.
IComponentInitializer
It has two methods which give a choice to hook the creation of new and
existing components. But i've not investigate if this is true for all the
cases you expose.

Regards,
Mario Vazquez

"Carlos J. Quintero [VB MVP]" <nospam@nospam.com> escribió en el mensaje
news:eJX8VruOHHA.4604@TK2MSFTNGP06.phx.gbl...
[quoted text, click to view]

Re: How to know when a component is draged on a form? Carlos J. Quintero [VB MVP]
1/22/2007 3:55:04 PM
Ah, yes, I found that interface sometime ago but I don't know how to use it
from outside a control designer (from an add-in, for example). Let me know
if you get more info.


--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com


"Mario Vázquez" <alguien@microsoft.com> escribió en el mensaje
news:epNKZDxOHHA.5064@TK2MSFTNGP04.phx.gbl...
[quoted text, click to view]
Re: How to know when a component is draged on a form? Mario Vázquez
1/23/2007 12:09:26 PM
Hi Carlos,

I still have'nt work with add-ins and macros, so I cannot properly talk
about it, but I'll explain you how I use this interface through the designer
of a component, and perhaps it helps you.
Anyway, I was testing the points you expose in your previous message, and
this interface does'nt solve them.

// Make the designer implements IComponentInitializer
class MyComponentDesigner:System.ComponentModel.Design.ComponentDesigner,
IComponentInitializer
{
...

// Implement the interface
void
IComponentInitializer.InitializeExistingComponent(System.Collections.IDictionary
defaultValues)
{
base.InitializeExistingComponent(defaultValues);
// hook point
}

void
IComponentInitializer.InitializeNewComponent(System.Collections.IDictionary
defaultValues)
{
base.InitializeNewComponent(defaultValues);
// hook point }
}
}

"Carlos J. Quintero [VB MVP]" <nospam@nospam.com> escribió en el mensaje
news:eeejPVjPHHA.3872@TK2MSFTNGP06.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button