Ejemplo n.º 1
0
        //Описание кнопки добавления элемента
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            ElementInfoForm Form1 = new ElementInfoForm();

            if (Form1.ShowDialog() == DialogResult.OK)
            {
                var element = Form1.Element;
                this.dataGridViewList.Rows.Add(element.Name, element.Value);
                ElementList.listElement.Add(element);
                listElementControl.elementControl = element;//ElementList.listElement[dataGridViewList.SelectedCells[0].RowIndex-1];
            }
        }
Ejemplo n.º 2
0
 //Описание кнопки изменения данных через calculateform
 private void buttonModify_Click(object sender, EventArgs e)
 {
     if (dataGridViewList.Rows.Count == 0)
     {
         MessageBox.Show("Список пуст");
     }
     else
     {
         ElementInfoForm ModifyForm  = new ElementInfoForm();
         int             ModifyIndex = dataGridViewList.CurrentCell.RowIndex;
         ModifyForm.Element = ElementList.listElement[ModifyIndex];
         if (ModifyForm.ShowDialog() == DialogResult.OK)
         {
             var newElement = ModifyForm.Element;
             ElementList.listElement.Insert(dataGridViewList.SelectedCells[0].RowIndex, newElement);
             ElementList.listElement.RemoveAt(dataGridViewList.SelectedCells[0].RowIndex + 1);
             dataGridViewList.Rows.Clear();
             foreach (var data in ElementList.listElement)
             {
                 dataGridViewList.Rows.Add(data.Name, data.Value);
             }
         }
     }
 }