コード例 #1
0
        /// <summary>
        /// Example to duplicate a Windows form control.
        /// </summary>
        private void DuplicateGroupBox()
        {
            GroupBox mainGroupBox       = ( GroupBox )this.MainPanel.Controls[0];
            GroupBox duplicatedGroupBox = ( GroupBox )ControlInitializer.DuplicateControl(mainGroupBox);

            this.SubPanel.Controls.Add(duplicatedGroupBox);
        }
コード例 #2
0
        private void ClearSubPanel()
        {
            GroupBox subGroupBox = ( GroupBox )this.SubPanel.Controls[0];

            ControlInitializer.RemoveAllEvents(subGroupBox);
            subGroupBox.Parent = null;
            subGroupBox.Dispose();
        }
コード例 #3
0
        private void InitializeMainPanel()
        {
            if (this.MainPanel.HasChildren)
            {
                GroupBox existGroupBox = ( GroupBox )this.MainPanel.Controls[0];
                ControlInitializer.RemoveAllEvents(existGroupBox);
                existGroupBox.Parent = null;
                existGroupBox.Dispose();
            }

            GroupBox mainGroupBox = new GroupBox();

            mainGroupBox.Text         = "GroupBox";
            mainGroupBox.Dock         = DockStyle.Fill;
            mainGroupBox.SizeChanged += (s, e) => { this.AppendMessage(s, $"GroupBox size changed."); };
            this.MainPanel.Controls.Add(mainGroupBox);

            TabControl tabControl = new TabControl();

            tabControl.Dock = DockStyle.Fill;
            tabControl.SelectedIndexChanged += (s, e) => { this.AppendMessage(s, "Selected tab page changed."); };
            mainGroupBox.Controls.Add(tabControl);

            Button button = new Button();

            button.Text   = "Button";
            button.Click += (s, e) => { this.AppendMessage(s, "Button clicked."); };

            TextBox textBox = new TextBox();

            textBox.TextChanged += (s, e) => { this.AppendMessage(s, "Text changed."); };

            CheckBox checkBox = new CheckBox();

            checkBox.Text = "CheckBox";
            checkBox.CheckStateChanged += (s, e) => { this.AppendMessage(s, $"CheckBox state changed. Current : { ( ( CheckBox )s ).CheckState}"); };

            RadioButton radioButton1 = new RadioButton();

            radioButton1.Text            = "RadioButton 1";
            radioButton1.Checked         = true;
            radioButton1.CheckedChanged += (s, e) => { this.AppendMessage(s, $"RadioButton 1 state changed. Current : { ( ( RadioButton )s ).Checked}"); };

            RadioButton radioButton2 = new RadioButton();

            radioButton2.Text            = "RadioButton 2";
            radioButton2.Checked         = false;
            radioButton2.CheckedChanged += (s, e) => { this.AppendMessage(s, $"RadioButton 2 state changed. Current : {( ( RadioButton )s ).Checked}"); };

            this.AddTabPage(tabControl, "Controls 1", button, textBox);
            this.AddTabPage(tabControl, "Controls 2", checkBox, radioButton1, radioButton2);
        }
コード例 #4
0
        /// <summary>
        /// Example to remove all event handler delegates from a Windows form control.
        /// </summary>
        private void RemoveSubGroupBoxEvents()
        {
            GroupBox subGroupBox = ( GroupBox )this.SubPanel.Controls[0];

            ControlInitializer.RemoveAllEvents(subGroupBox);
        }
コード例 #5
0
        /// <summary>
        /// Example to replace a Windows form control to another one.
        /// </summary>
        private void ReplaceMainGroupBox()
        {
            GroupBox mainGroupBox = ( GroupBox )this.MainPanel.Controls[0];

            ControlInitializer.ReplaceControl(mainGroupBox, new HecticGroupBox());
        }