title: Re-using same method in multiple windows forms
body: <p>I would like to ask for your help. Will you help captain newbie once again? :)</p>
  
  <p>I have several windows forms where I use datagridview. I would like to format the datagridviews in the same way on all the forms (e.g. AllowUserToAddRows = false;). </p>
  
  <p>To do this I created a class MYFormatting and method as below. I am going to use composition to re-use this method on multiple forms. I would be grateful if you could let tell me if my approach is correct?</p>
  
  <pre><code>public class MyFormating
      {
          public void FormatDGV(DataGridView dgv)
          {
              dgv.AllowUserToAddRows = false;
              dgv.AllowUserToDeleteRows = false;
              dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
              dgv.ColumnHeadersVisible = false;
              dgv.RowHeadersVisible = false;
              dgv.MultiSelect = false;
          }
      }
  </code></pre>
  
  <p>When initializing new form</p>
  
  <pre><code>Form1 frmForm1 = new Form1(new MyFormating());
  </code></pre>
  
  <p>Then in each form I am going to call myFormat method and pass datagridview.</p>
  
  <pre><code>public partial class Form1 : Form
  {
      private readonly MyFormating _myFormat;
  
      public Managers(MyFormating myFormat)
      {
          InitializeComponent();
          _myFormat = myFormat;
          _myFormat.FormatDGV(dgvManagers);
  </code></pre>
  
  <hr>
  
  <p>Leaving MyFormatting class as it is and then changing my Form1 code to below would give me same result. Is this still composition? Should I do something like this or convention rather say to follow the way I described above?</p>
  
  <p>When initializing new form</p>
  
  <pre><code>Managers frmManagers = new Managers();
  </code></pre>
  
  <p>Then in each form I am going to create new MyFormatting instance and pass datagridview to it's method</p>
  
  <pre><code>public partial class Form1: Form
      {
          private readonly MyFormating _myFormat;
  
          public Form1()
          {
              InitializeComponent();
              myFormat = new MyFormating();
              myFormat.FormatDGV(dgvManagers);
  </code></pre>