views:

125

answers:

1

I have a few (1-3) user controls on my form. I want to be able to click a button on my form (that is not part of the user controls) and have all 3 of my user controls respond. How can I do this?

+3  A: 

If I understand you correctly, this is all you need to do; just add a public method to your user control and call that method from your button press:

protected void Button_Click(object sender, EventArgs e)
{
   UserControl1.DoMethod();
   UserControl2.DoMethod();
   UserControl3.DoMethod();
}

public class YourUserControl : UserControl
{ 
   public void DoMethod()
   {
      // Show your ListBoxes
   }
}
GenericTypeTea
+1, was going to post the same answer.
Sorin Comanescu
Thanks! And now I feel like an idiot! This is what happens when I stay up all night.
Bob Dylan