Such as a Label and a TextBox.
I tried:
class MyClass : ToolStripPanel
{
//...
}
And the like. But then:
contextMenuStrip1.Items.Add(new MyClass());
shows an error:
...invalid arguments.
Such as a Label and a TextBox.
I tried:
class MyClass : ToolStripPanel
{
//...
}
And the like. But then:
contextMenuStrip1.Items.Add(new MyClass());
shows an error:
...invalid arguments.
You can use the ToolStripControlHost class to host any Windows Forms control on a ContextMenuStrip (or indeed any of the Strip controls)
For example, the following code will add a label to a context menu strip:
Label newlabel = new Label();
newlabel.Text = "Hello World";
newlabel.Width = 300;
ToolStripControlHost tsHost = new ToolStripControlHost(newlabel);
contextMenuStrip1.Items.Add(tsHost);