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 / Windows Forms / Design Time / April 2005

Tip: Looking for answers? Try searching our database.

Design Time event generation and method content

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fujiyama@gmail.com - 06 Apr 2005 00:02 GMT
Hi!
I'm trying to figure out how to create a control which can add or edit
code during drag&drop operation. I know how to handle CreateTransaction
method and add the control but I have no idea how to add event code
content during this operation.
For example, I would like to add the MyButton control which after drop
on Form will add Click event handler (+=new EventHandler to
ComponentDesigner generatated code) and put myButton_Click method with
some code inside.

I don't know if should I play with
System.CodeDom.CodeAttachEventStatement or maybe there is another
method?
I cannot find any example of such a thing. Sorry for my english :)

Mikolaj
Mujdat Dinc - 06 Apr 2005 14:47 GMT
Hi..
To bind an event this helps  you..
You can do this in your customtoolitem on CreateComponentCore function or
set set on your componet or initilize on your designer...

IEventBindingService eventservice =
(IEventBindingService)this.Component.Site.GetService(typeof(System.ComponentModel.Design.IEventBindingService));
  if( eventservice != null )
  {
   // Attempt to obtain a PropertyDescriptor for a
   EventDescriptorCollection edc =
TypeDescriptor.GetEvents(this.Component);
   if( edc == null || edc.Count == 0 )
    return;

   EventDescriptor ed = null;

   foreach(EventDescriptor edi in edc)
    if(edi.Name == "Click")
    {
     ed = edi;
     break;
    }
   if( ed == null )
    return;

   // Use the IEventBindingService to get a
   // PropertyDescriptor for the event.
   PropertyDescriptor pd = eventservice.GetEventProperty(ed);
   if( pd == null )
    return;

   // Set the value of the event to "testEventHandler".
   pd.SetValue(this.Component, "testEventHandler");
  }

----- Original Message -----
From: <fujiyama@gmail.com>
Newsgroups: microsoft.public.dotnet.framework.windowsforms.designtime
Sent: Wednesday, April 06, 2005 2:02 AM
Subject: Design Time event generation and method content

> Hi!
> I'm trying to figure out how to create a control which can add or edit
[quoted text clipped - 12 lines]
>
> Mikolaj

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.