How to add menu to a Component Class?

I've just created a solution and added a 'Component Class' to it.

All I need is to add a menu to Component Class when it is in the componentbar of a win-form, like the ImageList component of .NET.

Can anyone help me?

Answers


I assume you are referring to the little tiny arrow that appears on the ImageList component when you select it and you see a list of options. That requires a custom ComponentDesigner.

Make references to:

System.Components.Design
System.Design
System.Windows.Forms.Design

Here is a simple little component example:

[Designer(typeof(TestComponentDesigner))]
public class TestComponent : Component {

  public class TestComponentDesigner : ComponentDesigner {
    private DesignerVerbCollection verbs = new DesignerVerbCollection();

    public override void Initialize(IComponent component) {
      base.Initialize(component);
      verbs.Add(new DesignerVerb("Say Hello", new EventHandler(SayHello)));
    }

    public override DesignerVerbCollection Verbs {
      get {
        return verbs;
      }
    }

    private void SayHello(object sender, EventArgs e) {
      MessageBox.Show("Hello");
    }
  }
}

Results:

For more information, see Writing Custom Designers for .NET Components


Need Your Help

What do the Git “pairing broken” and “unknown” statuses mean, and when do they occur?

git git-diff

Some options in git diff, for instance --name-status, cause the output of a status letter next to a file name. They are:

The result of stored procedure to a table, without creating the table manually in SQL Server

sql-server tsql stored-procedures sql-server-2000

What I need to do is, put the results of stored procedure (with lots of parameters) in to a table. Something like that:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.