Example #1
0
 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;
         EditCustomer FormEdit = new EditCustomer();
         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;
     }
 }
Example #2
0
        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());
                EditCustomer FormEdit = new EditCustomer();
                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;
                //Обновляем DataGridRow
                if (mdlData.statusEdit != false)
                {
                    UpdateSourceGrid();
                    mdlData.statusEdit = false;
                }
                //После обновления возвращаем индекс:
                dataGridView1.ClearSelection();
                dataGridView1.Rows[currIndex].Selected        = true;
                dataGridView1.FirstDisplayedScrollingRowIndex = currIndex;
            }
        }
Example #3
0
 public frmKalendarEdit(EditCustomer form)
 {
     InitializeComponent();
     _owner = form;
 }