private void clbPortsList_SelectedIndexChanged(object sender, EventArgs e)
        {
            int item = this.clbPortsList.SelectedIndex;

            String PortName = "";

            if (item != -1)
            {
                PortName = (String)this.clbPortsList.Items[item];
            }

            if (item == -1 || !(PortName.Length > 0))
            {
                this.btnStart.Enabled = this.clbPortsList.CheckedItems.Count > 0;
                return;
            }

            lock (this.clbPortsList) {
                if (clbPortsList.GetItemChecked(item) == true)
                {
                    /* Insert Page */

                    SerialPortControl myComControl;
                    if (dynamicComControl.TryGetValue(PortName, out myComControl) == false)
                    {
                        myComControl = new SerialPortControl();
                        myComControl.setPortName(PortName);
                        dynamicComControl.Add(PortName, myComControl);
                        // Eventuali settaggi...
                    }

                    TabPage myPage;
                    if (dynamicPages.TryGetValue(PortName, out myPage) == false)
                    {
                        myPage      = new TabPage();
                        myPage.Text = PortName;
                        // Settaggi Pagina...

                        myPage.Controls.Add(myComControl);

                        dynamicPages.Add(PortName, myPage);
                    }

                    tabControl.TabPages.Add(myPage);
                }
                else if (clbPortsList.GetItemChecked(item) == false)
                {
                    /* Remove Page */

                    TabPage myPage = new TabPage();
                    if (dynamicPages.TryGetValue(PortName, out myPage) == true)
                    {
                        tabControl.TabPages.Remove(myPage);
                        dynamicPages.Remove(PortName);
                    }
                }

                this.btnStart.Enabled = this.clbPortsList.CheckedItems.Count > 0;
            }
        }
 private void btnStop_Click(object sender, EventArgs e)
 {
     this.btnStop.Enabled = false;
     foreach (KeyValuePair <String, SerialPortControl> entry in this.dynamicComControl)
     {
         SerialPortControl myControl = entry.Value;
         myControl.StopPort();
     }
     this.btnStart.Enabled = true;
 }