コード例 #1
0
        /// <summary>
        /// This method is called from two directions: it's called (via UpdateView) when the user has
        /// changed the width of the panel that this control is in (after UpdateView re-width's 'this'),
        /// which means that all the controls embedded in this control must be re-height'd as well.
        /// In this case, it is appropriate to pass the delegate for the "ReheightAllControls" so that
        /// that method can be called just prior to calling Adjust Height.
        /// The other direction this is called is when the user has forced an increase in a Text box
        /// that is necessatiating the parent control(s) (possibly all the way up the chain) to reheight
        /// themselves as well. In this case, we don't need to resize all the controls in any given
        /// form, but again, all the way up the chain.
        /// </summary>
        /// <param name="myDelegate"></param>
        protected void AdjustHeightWithSuspendLayout(ReheightAllControlsDelegate myDelegate)
        {
            SuspendLayout();
            tableLayoutPanel.SuspendLayout();

            bool bBeingCalledFromUpdateHeight = (myDelegate != null);

            if (bBeingCalledFromUpdateHeight)
            {
                myDelegate();
            }

            AdjustHeight();

            tableLayoutPanel.ResumeLayout(false);
            tableLayoutPanel.PerformLayout();
            ResumeLayout(false);
            PerformLayout();

            // if we have a parent (e.g. the sub-controls like AnchorControl do) AND
            //  we aren't being called from UpdateView above (where the Parent will
            //  be done in it's own course), then call the parent to update the height
            //  (this is basically so that if we resize the Anchor because the user
            //  entered an exegetical comment, then the parent Verse control needs
            //  to resize also).
            if ((ParentControl != null) && (!bBeingCalledFromUpdateHeight))
            {
                ParentControl.AdjustHeightWithSuspendLayout(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// Begins the UpdateView process by suspending the layout and fixing this control's width
        /// Subclasses will call this at the start of their implementation of UpdateView
        /// </summary>
        /// <param name="nWidth">This parameter is used to fix the width of the control (the parent knows what the width is)</param>
        public void UpdateHeight(int nWidth)
        {
            if (Width != nWidth)
            {
                tableLayoutPanel.SuspendLayout();
                SuspendLayout();

                Width = nWidth;

                // first resume and perform the layout. This causes all, for example, Dock=Fill TextBox's
                // to have their width's set
                tableLayoutPanel.ResumeLayout(false);
                tableLayoutPanel.PerformLayout();
                ResumeLayout(false);
                PerformLayout();
            }

            // now reheight all the controls
            ReheightAllControlsDelegate myDelegate = new ReheightAllControlsDelegate(ReheightAllControls);

            AdjustHeightWithSuspendLayout(myDelegate);
        }