title: Access data in EventArgs Class
body: <p>I am trying to access data store in ResultID from the following code:</p>
  
  <pre><code>public class ResultPanelEventArgs : EventArgs
  {
      private string stringResultId = string.Empty;
      private int intRowIndex = -1;
      private string stringAnalysisName = string.Empty;
      private DateTime dateTimeAnalysisDateTime;
  
      /// &lt;summary&gt;
      /// Gets or sets the row index of selected result.
      /// &lt;/summary&gt;
      public int RowIndex
      {
          get { return intRowIndex; }
          set { intRowIndex = value; }
      }
  
      /// &lt;summary&gt;
      /// Gets or sets the result id of selected result.
      /// &lt;/summary&gt;
      public string ResultId
      {
          get { return stringResultId; }
          set { stringResultId = value; }
      }
  
      /// &lt;summary&gt;
      /// Gets or sets the date and time of the selected result.
      /// &lt;/summary&gt;
      public DateTime AnalysisDateTime
      {
          get { return dateTimeAnalysisDateTime; }
          set { dateTimeAnalysisDateTime = value; }
      }
  
      /// &lt;summary&gt;
      /// Gets or sets the name of the sample as Analysis name.
      /// &lt;/summary&gt;
      public string AnalysisName
      {
          get { return stringAnalysisName; }
          set { stringAnalysisName = value; }
      }
  };
  </code></pre>
  
  <p>I have a method to pull the info:</p>
  
  <pre><code>private string GetResultID(object sender, ResultPanelEventArgs e)
      {        
  
  
          string resultID = string.Empty;
          resultID = e.ResultId.ToString();
          return resultID;           
  
      }
  </code></pre>
  
  <p>but cannot seem to call that method (I get Argument errors). I am somewhat new to c# and have never worked with EventArgs so I don't even know if this is possible. Any advice on how to access the data stored here? </p>
  
  <p>Per request here are three methods that appear to populate ResultId:</p>
  
  <pre><code>private ResultPanelEventArgs GetDataForTheGivenRowIndex(int intRowIndex)
      {
          ResultPanelEventArgs resultPanelEventArgs = new ResultPanelEventArgs();
          resultPanelEventArgs.RowIndex = intRowIndex;
          try
          {
              if (intRowIndex &gt;= 0 &amp;&amp; intRowIndex &lt; dataGridViewResultView.Rows.Count)
              {
                  object objectResultId = null;
                  if (dataGridViewResultView.Columns.Contains("ColumnResultId") == true)
                  {
                      objectResultId = dataGridViewResultView.Rows[intRowIndex].Cells["ColumnResultId"].Value;
                  }
                  else
                  {
                      objectResultId = dataGridViewResultView.Rows[intRowIndex].Tag;
                  }
                  if (objectResultId != null)
                  {
                      resultPanelEventArgs.ResultId = objectResultId.ToString();
                  }
  
                  object objectAnalysisName = null;
                  if (dataGridViewResultView.Columns.Contains("ColumnAnalysis") == true)
                  {
                      objectAnalysisName = dataGridViewResultView.Rows[intRowIndex].Cells["ColumnAnalysis"].Value;
                  }
                  else
                  {
                      objectAnalysisName = dataGridViewResultView.Rows[intRowIndex].Tag;
                  }
                  if (objectAnalysisName != null)
                  {
                      resultPanelEventArgs.AnalysisName = objectAnalysisName.ToString();
                  }
  
                  object objectAnalysisDateTime = null;
                  if (dataGridViewResultView.Columns.Contains("ColumnDate") == true)
                  {
                      objectAnalysisDateTime = dataGridViewResultView.Rows[intRowIndex].Cells["ColumnDate"].Value;
                  }
                  else
                  {
                      objectAnalysisDateTime = dataGridViewResultView.Rows[intRowIndex].Tag;
                  }
                  if (objectAnalysisDateTime != null)
                  {
                      resultPanelEventArgs.AnalysisDateTime = 
                               Utilities.ConvertStringToDateTime(objectAnalysisDateTime.ToString());
                  }
              }
          }
          catch
          {
              resultPanelEventArgs = null;
              //Nothing to do
          }
          return resultPanelEventArgs;
      }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>private ResultPanelEventArgs GetDataForTheGivenResultID(string stringResultId)
      {
          ResultPanelEventArgs resultPanelEventArgs = null;
          try
          {
              foreach (DataGridViewRow dataGridViewRow in dataGridViewResultView.Rows)
              {
                  if (dataGridViewRow != null)
                  {
                      if (dataGridViewRow.Index &gt;= 0)
                      {
                          if (dataGridViewRow.Cells["ColumnResultId"] != null)
                          {
                              if (dataGridViewRow.Cells["ColumnResultId"].Value.ToString() == stringResultId)
                              {
                                  //Create the ResultPanelEventArgs
                                  object objectResultId = dataGridViewRow.Cells["ColumnResultId"].Value;
                                  object objectAnalysisName = dataGridViewRow.Cells["ColumnAnalysis"].Value;
                                  object objectAnalysisDateTime = dataGridViewRow.Cells["ColumnDate"].Tag;
                                  resultPanelEventArgs = new ResultPanelEventArgs();
  
                                  if (objectResultId != null)
                                  {
                                      resultPanelEventArgs.RowIndex = dataGridViewRow.Index;
                                      resultPanelEventArgs.ResultId = objectResultId.ToString();
                                      resultPanelEventArgs.AnalysisName = objectAnalysisName.ToString();
                                      resultPanelEventArgs.AnalysisDateTime = (DateTime)objectAnalysisDateTime;
                                  }
  
                                  dataGridViewRow.Selected = true;
                                  break;
                              }
                          }
                      }
  
                  }
  
              }
          }
          catch
          {
              resultPanelEventArgs = null;
              //Nothing to do
          }
          return resultPanelEventArgs;
      }
  </code></pre>
  
  <p>and</p>
  
  <pre><code> private void dataGridViewResultList_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
      {
          try
          {
              if (e.RowIndex &gt;= 0)
              {
                  this.result = this.GetResult(e.RowIndex);
  
                  ResultPanelEventArgs resultPanelEventArgs = new ResultPanelEventArgs();
                  resultPanelEventArgs.ResultId = this.result.Id.ToString();
                  resultPanelEventArgs.RowIndex = this.dataGridViewResultList.SelectedRows[0].Index;
  
                  if (this.DoubleClicked != null)
                  {
                      this.DoubleClicked(sender, resultPanelEventArgs);
                  }
  
                  this.DialogResult = DialogResult.OK;
              }
          }
          catch (Exception ex)
          {
              UICommon.LogError(ex);
          }
      }
  </code></pre>