Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mario Vázquez - 17 Jan 2007 14:56 GMT
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
Carlos J. Quintero [VB MVP] - 18 Jan 2007 10:24 GMT
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.

Signature

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

> Hi all,
> I'm trying to build a component which takes advantage of other components.
[quoted text clipped - 7 lines]
> Thanks for attention,
> Mario Vazquez
Mario Vázquez - 18 Jan 2007 14:57 GMT
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

> Hi,
>
[quoted text clipped - 20 lines]
>> Thanks for attention,
>> Mario Vazquez
Carlos J. Quintero [VB MVP] - 22 Jan 2007 14:55 GMT
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.

Signature

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

> Hi Carlos,
>
[quoted text clipped - 8 lines]
> Regards,
> Mario Vazquez
Mario Vázquez - 23 Jan 2007 11:09 GMT
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  }
  }
}

> 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
[quoted text clipped - 12 lines]
>> Regards,
>> Mario Vazquez

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.