示例#1
0
        public static void Remove(Control.ControlCollection coll, Control item)
        {
            if ((coll != null) && (item != null))
            {
                Button tempButton = null;
                Form parentForm = item.FindForm();

                if (parentForm != null)
                {
                    // Create a hidden, temporary button
                    tempButton = new Button();
                    tempButton.Visible = false;

                    // Add this temporary button to the parent form
                    parentForm.Controls.Add(tempButton);

                    // Must ensure that temp button is the active one
                    parentForm.ActiveControl = tempButton;
                }

                // Remove our target control
                coll.Remove(item);

                if (parentForm != null)
                {
                    // Remove the temporary button
                    tempButton.Dispose();
                    parentForm.Controls.Remove(tempButton);
                }
            }
        }
示例#2
0
    /// <summary>
    /// Replaces the controls in the form that was generated by the gui designer
    /// </summary>
    /// <param name="controls">The controls container which contains the controls that are to be replaced</param>
    /// <param name="originalControl">The control to replace</param>
    /// <param name="replacement">The replacement</param>
    protected static void ReplaceControl(Control.ControlCollection controls, Control originalControl, Control replacement)
    {
      if (originalControl == null)
        return;

      var location = originalControl.Location;
      var originalSize = originalControl.Size;
      var tabIndex = originalControl.TabIndex;

      controls.Remove(originalControl);

      if (replacement != null)
      {
        controls.Add(replacement);
        replacement.Location = location;
        replacement.Size = originalSize;
        replacement.TabIndex = tabIndex;
      }
    }
 public void removeFrom(Control.ControlCollection controls)
 {
     controls.Remove(depthTextBox);
     controls.Remove(statusLabel);
     controls.Remove(amountTextBox);
     controls.Remove(deleteCheckBox);
 }
 internal void RemoveControls(Control.ControlCollection controls)
 {
     for (int i = 0; i < this._addedControls.Count; i++)
     {
         Control control = this._addedControls[i];
         control.Tag = null;
         controls.Remove(control);
     }
 }
示例#5
0
        /// <summary>
        /// フォーム上の、コントロールを除外していきます。
        /// メインウィンドウ自身は除外せず残します。
        /// 
        /// todo:イベントハンドラーを外してから、フォームを外すこと。リストボックスが誤挙動を起こしている。
        /// </summary>
        /// <param name="formControls"></param>
        /// <param name="log_Reports"></param>
        public void ClearForms(
            Control.ControlCollection formControls,
            Log_Reports log_Reports
            )
        {
            //
            //
            //
            //()メソッド開始
            //
            //
            //
            Log_Method log_Method = new Log_MethodImpl(1, Log_ReportsImpl.BDebugmode_Static);
            log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "ClearForms",log_Reports);

            if (log_Reports.Successful)
            {
                Control mainwnd = this.Mainwnd_FormWrapping.Form;

                //
                //
                //
                //(1)フォームに登録されているコントロール全ての、イベントハンドラーを外す。
                //
                //
                //
                this.Owner_MemoryApplication.MemoryForms.ForEach_Children(delegate(string sKey, Usercontrol uct, ref bool bRemove, ref bool bBreak)
                {
                    if (log_Reports.Successful)
                    {
                        if (mainwnd != uct)
                        {
                            uct.ClearAllEventhandlers(log_Reports);
                        }
                        else
                        {
                            log_Method.WriteDebug_ToConsole("(1)メインウィンドウを除く。");
                        }
                    }
                });

                //
                //
                //
                //(2)フォームに登録されているコントロール全てを、クリアーする。
                //
                //
                //
                this.Owner_MemoryApplication.MemoryForms.ForEach_Children(delegate(string sKey, Usercontrol uct, ref bool bRemove, ref bool bBreak)
                {
                    if (log_Reports.Successful)
                    {
                        if (mainwnd != uct)
                        {
                            uct.Clear();
                        }
                        else
                        {
                            log_Method.WriteDebug_ToConsole("(2)メインウィンドウを除く。");
                        }
                    }
                });

                //
                //
                //
                //(3)フォームを構成しているカスタム・コントロール全てを、破棄する。
                //
                //
                //
                this.Owner_MemoryApplication.MemoryForms.ForEach_Children(delegate(string sKey, Usercontrol uct, ref bool bRemove, ref bool bBreak)
                {
                    if (log_Reports.Successful)
                    {
                        if (mainwnd != uct)
                        {
                            uct.DestractAllCustomcontrols(log_Reports);
                        }
                        else
                        {
                            log_Method.WriteDebug_ToConsole("(3)メインウィンドウを除く。");
                        }
                    }
                });

                //
                //
                //
                //(4)フォームに登録されているコントロール全てを、除外する。
                //
                //
                //
                this.Owner_MemoryApplication.MemoryForms.ForEach_Children(delegate(string sKey, Usercontrol uct, ref bool bRemove, ref bool bBreak)
                {
                    if (log_Reports.Successful)
                    {
                        if (mainwnd != uct)
                        {
                            formControls.Remove((Control)uct);
                        }
                        else
                        {
                            log_Method.WriteDebug_ToConsole("(4)メインウィンドウを除く。");
                        }
                    }
                });

                //
                // CSVExEに登録されているコントロールの一覧を空にします。
                //
                this.Clear(this.Owner_MemoryApplication);
                //this.dic_Item.Add(NamesSc.S_MAINWND, (Usercontrol)mainwnd);
            }

            //
            //
            //
            //
            log_Method.EndMethod(log_Reports);
        }
示例#6
0
 public static void NewControl(Control.ControlCollection controls, ref UserControl oldControl, UserControl newControl)
 {
     controls.Remove(oldControl);
     oldControl = newControl;
     controls.Add(oldControl);
 }