/// <summary>
        /// Adds a new ComboBoxElement to the dialog and to the Elements arraylist.
        /// </summary>
        /// <returns></returns>
        public ComboBoxElement Add_ComboBoxElement()
        {
            ComboBoxElement MyComboboxElement = new ComboBoxElement();

            Elements.Add(MyComboboxElement);
            this.panelElementContainer.Controls.Add(MyComboboxElement);
            Initialize_Element(MyComboboxElement);
            return(MyComboboxElement);
        }
        void Initialize_Element(ComboBoxElement MyElement)
        {
            MyElement.Location           = new System.Drawing.Point(3, 10 + ((Elements.Count - 1) * 55));
            MyElement.Name               = "Element" + Elements.Count;
            MyElement.Size               = new System.Drawing.Size(457, 45);
            MyElement.Status             = ComboBoxElement.LightStatus.Empty;
            MyElement.ResizeStarted     += new ComboBoxElement.ResizeStartedHandler(Element_ResizeStarted);
            MyElement.ResizeEnded       += new ComboBoxElement.ResizeEndedHandler(Element_ResizeEnded);
            MyElement.HelpButtonPressed += new ComboBoxElement.HelpButtonHandler(Element_HelpButtonPressed);
            MyElement.HelpImage          = MyElement.DefaultImage;
            int myWidth = this.panelElementContainer.Width - MyElement.Left - 10;

            MyElement.Anchor            = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | System.Windows.Forms.AnchorStyles.Top)));
            MyElement.Size              = new System.Drawing.Size(myWidth, 45);
            MyElement.ResizeGripVisible = false;
            MyElement.Clicked          += new EventHandler(panelElementContainer_Click);
        }
 private void cmdOK_Click(object sender, EventArgs e)
 {
     for (int I = 0; I < Elements.Count; I++)
     {
         Type elType = Elements[I].GetType();
         if (elType == typeof(FileElement))
         {
             FileElement fe = Elements[I] as FileElement;
             if (fe.Halt == true)
             {
                 string caption = fe.Caption;
                 string text;
                 text = "The value you entered for " + caption + " has the following error:\n" +
                        fe.LightMessage + "\n";
                 MessageBox.Show(text, "Some Parameters are invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
         }
         if (elType == typeof(LayerFileElement))
         {
             LayerFileElement fe = Elements[I] as LayerFileElement;
             if (fe.Halt == true)
             {
                 string caption = fe.Caption;
                 string text;
                 text = "The value you entered for " + caption + " has the following error:\n" +
                        fe.LightMessage + "\n";
                 MessageBox.Show(text, "Some Parameters are invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
         }
         else if (elType == typeof(TextElement))
         {
             TextElement fe = Elements[I] as TextElement;
             if (fe.Halt == true)
             {
                 string caption = fe.Caption;
                 string text;
                 text = "The value you entered for " + caption + " has the following error:\n" +
                        fe.LightMessage + "\n";
                 MessageBox.Show(text, "Some Parameters are invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
         }
         else if (elType == typeof(ComboBoxElement))
         {
             ComboBoxElement fe = Elements[I] as ComboBoxElement;
             if (fe.Halt == true)
             {
                 string caption = fe.Caption;
                 string text;
                 text = "The value you entered for " + caption + " has the following error:\n" +
                        fe.LightMessage + "\n";
                 MessageBox.Show(text, "Some Parameters are invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 return;
             }
         }
     }
     this.DialogResult = DialogResult.OK;
     if (!this.Modal)
     {
         this.Hide();
     }
 }