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 / June 2004

Tip: Looking for answers? Try searching our database.

Adding custom verbs for other controls on form in designer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Henning - 22 Jun 2004 12:23 GMT
Does anyone know if it is possible to add verbs in the designer to controls
that are NOT created by me?  For instance, whenever the user has an instance
of one of my manager components on their form and selects a control (such as
a Button, Label, or any other control not created by me), I would like to
add a verb "Do Something" to that Control's context menu and have it visible
in the verb area in the property grid.

Is this possible?  I believe Infragistics does this with their controls but
I haven't found any help on how to implement it.

Thanks for your help.

Bill
Jer_m - 24 Jun 2004 00:53 GMT
Hi Bill,

I'm doing something like this in my custom controls designer
I didn't try compiling it but I just modified it from some of my code
so hopefully it works.

private DesignerVerb SomeVerb;

public override void Initialize(IComponent component)
{
    base.Initialize (component);

    ISelectionService ss =
(ISelectionService)GetService(typeof(ISelectionService));

    if (ss != null)
        ss.SelectionChanged += new EventHandler(OnSelectionChanging);

    this.SomeVerb = new DesignerVerb("Invoke SomeVerb", new
EventHandler(SomeVerbHandler));
}

public void OnSelectionChanging(object sender, EventArgs e)
{
    ISelectionService ss =
(ISelectionService)GetService(typeof(ISelectionService));

    if( ss.PrimarySelection is Button ||
       ss.PrimarySelection is Label
    {       
        IDesignerHost dh = (IDesignerHost)
this.GetService(typeof(IDesignerHost));
        IDesigner dsgnr = (IDesigner)dh.GetDesigner(
(Control)ss.PrimarySelection );

        if( !dsgnr.Verbs.Contains() )
            dsgnr.Verbs.Add(SomeVerb);
    }
}

private void SomeVerbHandler(object sender, EventArgs e)
{
    MessageBox.Show("Do Something");
}

kind regards,
Jerron

> Does anyone know if it is possible to add verbs in the designer to controls
> that are NOT created by me?  For instance, whenever the user has an instance
[quoted text clipped - 9 lines]
>
> Bill
Bill Henning - 24 Jun 2004 23:27 GMT
Thanks Jerron... that works!

> Hi Bill,
>
[quoted text clipped - 57 lines]
> >
> > Bill

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.