Exemple #1
0
        public static void SetInnerMargin(this TextBoxBase textBox, int left, int top, int right, int bottom)
        {
            var rect = textBox.GetFormattingRect();

            var newRect = new Rectangle(left, top, rect.Width - left - right, rect.Height - top - bottom);

            textBox.SetFormattingRect(newRect);
        }
        public static (int left, int top, int right, int bottom) GetInnerMargins(this TextBoxBase textBox)
        {
            Rectangle rect = textBox.GetFormattingRect();

            int rightMargin  = textBox.ClientRectangle.Width - (rect.Width + rect.Left);
            int bottomMargin = textBox.ClientRectangle.Height - (rect.Height + rect.Top);

            var newRect = new Rectangle(rect.Left, rect.Top, rightMargin, bottomMargin); // Width = right, Height = bottom

            return(newRect.Left, newRect.Top, newRect.Width, newRect.Height);
        }
        // GetFormattingRect

        // *********************************************** set_margins

        public static void set_margins(this TextBoxBase textbox,
                                       int left,
                                       int top,
                                       int right,
                                       int bottom)
        {
            Rectangle rect      = textbox.GetFormattingRect();
            Rectangle rectangle = new Rectangle(
                left,
                top,
                (rect.Width - left - right),
                (rect.Height - top - bottom));

            textbox.SetFormattingRect(rectangle);
        }