title: C# Is there a way to cast 2 events in a function?
body: <p>I'm trying to make one function that will do some instructions for 2 (mouse) events in a DataGridView.
  In order to not repeat the instructions in both of events.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>        private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
          {
              if (e.ColumnIndex &gt;= 0 &amp;&amp; e.RowIndex &gt;= 0 &amp;&amp; dgv.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewLinkCell)
              { Process.Start(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value as string); }
          }
  
          private void dgv_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
          {
              if (e.ColumnIndex &gt;= 0 &amp;&amp; e.RowIndex &gt;= 0 &amp;&amp; dgv.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewLinkCell)
              { Process.Start(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value as string); }
          }
  </code></pre>
  
  <p>So far I've tried to do this:</p>
  
  <pre><code>        private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
          {
              ReLink(e);
          }
  
          private void dgv_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
          {
              ReLink(e);
          }
  
          //no matter which event I will specify, it is clear that it will only work for one event
          private void ReLink(DataGridViewCellMouseEventArgs e)
          {
              if (e.ColumnIndex &gt;= 0 &amp;&amp; e.RowIndex &gt;= 0 &amp;&amp; dgv.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewLinkCell)
              { Process.Start(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value as string); }
          }
  </code></pre>
  
  <p>So, is there a way to solve this?...</p>