Very easy, I'll write code, when user presses on the button, it creates object fron ListBox type and create an event for it also...
private void Grow(object sender, EventArgs e)
{
ListBox lstBoxForItems = new ListBox();
lstBoxForItems.Items.Add("1");
lstBoxForItems.Items.Add("2");
lstBoxForItems.Items.Add("3");
lstBoxForItems.Show();
this.Controls.Add(lstBoxForItems);
lstBoxForItems.SelectedIndexChanged += new EventHandler(lstBoxForItems_SelectedIndexChanged);
}
void lstBoxForItems_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show(lstBoxForItems.SelectedItem.ToString());
}
Reputation Points: 480
Solved Threads: 276
Postaholic
Offline 2,189 posts
since Aug 2006