How can I programmatically create a ToolStripDropDown
in a winform project ? I want to associate this item to a TextBox
(showing last entries) and it appears when clicking on a Button
.
It should be on the red line :
Edit : I actually have :
Class MyClass : UserControl
{
//Created in designer :
// Button buttonName;
// TextBox textboxName;
// List<String> lastNames;
// I want to create
ToolStripDropDown toolStripName;
public MyClass ()
{
toolStripName = new ToolStripDropDown();
toolStripName.OwnerItem = textboxName; // Want to define the textbox as owner
buttonName.Click += ButtonName_Click;
toolStripName.Items = lastNames; // I want to display the last names saved
}
private void ButtonName_Click(object sender, EventArgs e)
{
toolStripName.Show();
}
}
This code doesn't work. I never used a ToolStripDropDown
and I don't know how to use it.