Пример #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);
        }
Пример #2
0
        public static void SetInnerMargins(this TextBoxBase textBox, int left, int top, int right, int bottom)
        {
            //Rectangle rect = textBox.GetFormattingRect();

            //var newRect = new Rectangle(left, top, rect.Width - left - right, rect.Height - top - bottom);
            int rightMargin  = textBox.ClientRectangle.Width - (left + right);
            int bottomMargin = textBox.ClientRectangle.Height - (top + bottom);
            var newRect      = new Rectangle(left, top, rightMargin, bottomMargin);

            textBox.SetFormattingRect(newRect);
        }
        // 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);
        }