private void btnEdit_Click(object sender, EventArgs e)
        {
            Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected);

            if (selectedRowCount > 0)
            {
                string iRowString;
                int    row;
                iRowString = dataGridView1.SelectedRows[selectedRowCount - 1].Index.ToString();
                row        = Convert.ToInt32(iRowString.ToString());
                EditSellers FormEdit = new EditSellers();
                FormEdit.Owner         = this;
                FormEdit.ID            = Convert.ToInt32(dataGridView1.Rows[row].Cells[0].Value);
                FormEdit.NameObj       = dataGridView1.Rows[row].Cells[1].Value.ToString();
                FormEdit.NameClient    = dataGridView1.Rows[row].Cells[2].Value.ToString();
                FormEdit.NamePerformer = dataGridView1.Rows[row].Cells[3].Value.ToString();
                FormEdit.Show();
                //запоминаешь индекс выделенной строки
                int currIndex = 0;
                currIndex = dataGridView1.CurrentRow.Index;
                //Обновляем DataGrid
                if (mdlData.statusEdit != false)
                {
                    UpdateSourceGrid();
                    //dataGridView1.Rows[row].DataGridView.Update();
                    mdlData.statusEdit = false;
                }
                //После обновления возвращаем индекс:
                dataGridView1.ClearSelection();
                dataGridView1.Rows[currIndex].Selected        = true;
                dataGridView1.FirstDisplayedScrollingRowIndex = currIndex;
            }
        }
 private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
     {
         var v = dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString();
         int row;
         row = e.RowIndex;
         EditSellers FormEdit = new EditSellers();
         FormEdit.Owner         = this;
         FormEdit.ID            = Convert.ToInt32(dataGridView1.Rows[row].Cells[0].Value);
         FormEdit.NameObj       = dataGridView1.Rows[row].Cells[1].Value.ToString();
         FormEdit.NameClient    = dataGridView1.Rows[row].Cells[2].Value.ToString();
         FormEdit.NamePerformer = dataGridView1.Rows[row].Cells[3].Value.ToString();
         FormEdit.Show();
         //запоминаешь индекс выделенной строки
         int currIndex = 0;
         currIndex = dataGridView1.CurrentRow.Index;
         //Обновляем DataGrid
         if (mdlData.statusEdit != false)
         {
             UpdateSourceGrid();
             mdlData.statusEdit = false;
         }
         //После обновления возвращаем индекс:
         dataGridView1.ClearSelection();
         dataGridView1.Rows[currIndex].Selected        = true;
         dataGridView1.FirstDisplayedScrollingRowIndex = currIndex;
     }
 }
 public frmKalendarEditSellers(EditSellers form)
 {
     InitializeComponent();
     _owner = form;
 }