title: Application of grid view in c#
body: <p>There are some Forms and some Custom User controls (custom drop down window containing dataGridView ) in my project.in a Form(Purchase order) have a dataGridView control, when clicking a cell this custom dropdown window will appear, when selecting a row in that drop down window or by clicking ENTER key these values (ie, cell values  in a row of gridview) sholud moves to previous grid view of FORM. I tried this, can't get expected output...any one helpe...</p>
  
  <h2>portion of code in custom user control:-</h2>
  
  <pre><code>#region Declarations
      public string grdItmName;
      public string grdItmDisrption;
      public string grdItmCata;
      public string grdItmPrice;
      #endregion
  
      #region prop
      public string gridfield1
      {
          get
          {
              return grdItmName;
          }
          set { grdItmName = value; }
      }
  
      public string gridfield2
      {
          get
          {
              return grdItmDisrption;
          }
          set { grdItmDisrption = value; }
      }
      public string gridfield3
      {
          get
          {
              return grdItmCata;
          }
          set { grdItmCata = value; }
      }
      public string gridfield4
      {
          get
          {
              return grdItmPrice;
          }
          set { grdItmPrice = value; }
      }
  #endregion
  </code></pre>
  
  <hr>
  
  <pre><code>private void gridItemlist_KeyDown(object sender, KeyEventArgs e)
      {
          if (e.KeyCode.Equals(Keys.Enter))
          {
  
              try
              {
                  grdItmName = gridItemlist.SelectedRows[0].Cells[0].Value.ToString();
                  grdItmDisrption = gridItemlist.SelectedRows[0].Cells[1].Value.ToString();
                  grdItmCata = gridItemlist.SelectedRows[0].Cells[2].Value.ToString();
                  grdItmPrice = gridItemlist.SelectedRows[0].Cells[3].Value.ToString();
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message);
              }
          }
  
  
  }
  </code></pre>
  
  <hr>
  
  <p>code snippets of FORM grid view:--</p>
  
  <pre><code>private void gridPrchaseOrder_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  
  {
  
  
  customDropDown.Show();
  customDropDown.BringToFront();`// display in front of other controls`
  customDropDown.Select();
  customDropDown.Location = gridPrchaseOrder.PointToScreen(gridPrchaseOrder.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location);
  
  
  
  
          try
          {   
            int n = gridPrchaseOrder.Rows.Add();
            gridPrchaseOrder.Rows[n].Cells[0].Value = customDropDown.gridfield1;
              gridPrchaseOrder.Rows[n].Cells[1].Value = customDropDown.gridfield2;
              gridPrchaseOrder.Rows[n].Cells[2].Value = customDropDown.gridfield3;
              gridPrchaseOrder.Rows[n].Cells[3].Value = customDropDown.gridfield4;
              customDropDown.Focus();
          }
          catch (Exception ex) { MessageBox.Show(ex.Message); }
  
      }    
  </code></pre>