title: How to pass a user control and a property of a usercontrol in the parameters of a subroutine
body: <p>I am bringing a few user controls to my c# winform and I am basically doing the same thing again and again. Every time I click a button on the main form and one of the user controls is visible it calls a property of that user control to occur and if a different user control is visible it calls a different property of a that user control to occur since basically the same code is happening by the button click regardless of which user control is visible I would like to save code space and make a subroutine that essentially does the same thing it just uses a different user control and user control property per user control and I would like to have a parameter of the subroutine something like this</p>
  
  <pre><code>private void DoSomething(UserControl usercontrol, UserControlProperty property)
  {
      usercontrol.property
  }
  
  DoSomething(Products, Products.Fill);
  </code></pre>
  
  <p>I would like to do something like this although I don't know if it's possible I want to access the user control and also a property in the user control but and pass them into a subroutine as the parameters</p>
  
  <pre><code>Button1_Click(object sender, eventargs e)
  {
      UserControlDoSomething(usercontrol1, usercontrol1.FillDatagridview);
      UserControlDoSomething(usercontrol2, usercontrol2.FillDatagridview0;
  }
  
  UserControlDoSomething(UserControl u, ????)
  {
      u.backcolor = red;
      u.property();
  }
  </code></pre>
  
  <p>I don't know how to put a property of the user control in the parameter</p>
  
  <p>hope someone can help</p>