Example #1
0
 private void listBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if ((Items)listBox1.SelectedItem != null)
         {
             if (Remove_data == false)
             {
                 //Add
                 if (!to_SRI_listbox)
                 {
                     if (Data_type == true)
                     { // product
                         Main.listBox_products.Items.Add((Items)listBox1.SelectedItem);
                     }
                     else
                     { // reactant
                         Main.listBox_reactants.Items.Add((Items)listBox1.SelectedItem);
                     }
                 }
                 else
                 {
                     Calculation_control.listBox1.Items.Add((Items)listBox1.SelectedItem);
                 }
             }
             else
             {
                 if (!to_SRI_listbox)
                 {
                     //Remove
                     if (Data_type == true)
                     { // product
                         Main.listBox_products.Items.Remove((Items)listBox1.SelectedItem);
                     }
                     else
                     { // reactant
                         Main.listBox_reactants.Items.Remove((Items)listBox1.SelectedItem);
                     }
                 }
                 else
                 {
                     Calculation_control.listBox1.Items.Remove((Items)listBox1.SelectedItem);
                 }
             }
             if (!to_SRI_listbox)
             {
                 Main.listbox_change();
             }
             else
             {
                 Calculation_control.check_button();
             }
             this.Close();
         }
     }
 }
Example #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (Remove_data == false)
     {
         //Add
         if (!to_SRI_listbox)
         {
             if (Data_type == true)
             { // product
                 Main.listBox_products.Items.Add((Items)listBox1.SelectedItem);
             }
             else
             { // reactant
                 Main.listBox_reactants.Items.Add((Items)listBox1.SelectedItem);
             }
         }
         else
         {
             Calculation_control.listBox1.Items.Add((Items)listBox1.SelectedItem);
         }
     }
     else
     {
         if (!to_SRI_listbox)
         {
             //Remove
             if (Data_type == true)
             { // product
                 Main.listBox_products.Items.Remove((Items)listBox1.SelectedItem);
             }
             else
             { // reactant
                 Main.listBox_reactants.Items.Remove((Items)listBox1.SelectedItem);
             }
         }
         else
         {
             Calculation_control.listBox1.Items.Remove((Items)listBox1.SelectedItem);
         }
     }
     if (!to_SRI_listbox)
     {
         Main.listbox_change();
     }
     else
     {
         Calculation_control.check_button();
     }
     this.Close();
 }