hi every one.
i have a listBox.
and i am defining a ToolStripControlHost that host the listbox
and i am adding the host control to a ToolStripDropDown
now when changing the DataSource of the ListBox nothing happen and the listBOx is empty??
public class Person
{
public string Name { get; set; }
public Person(string name)
{
Name = name;
}
}
private void Form1_Load(object sender, EventArgs e)
{
ListBox lstBox = new ListBox();
lstBox.DataSource = new List<Person> { new Person("Nour"), new Person("Ahmad") };
lstBox.DisplayMember = "Name";
//Controls.Add(lstBox);
ToolStripControlHost host = new ToolStripControlHost(lstBox);
host.AutoSize = false;
ToolStripDropDown dropDown = new ToolStripDropDown();
dropDown.AutoClose = false;
dropDown.AutoSize = false;
dropDown.Items.Add(host);
dropDown.Show(this, 0, 0);
}
now if you uncomment the
Controls.Add(lstBox);
the listbox works fine???
what does that mean?
i code so , I'm exists.