1. use the mouse to control the position: Click the left button at any position to drag 2. use the mouse to control the size: in the lower right corner of the control, you can adjust the size of the cursor. use the keyboard to control the position: alt + direction key 4. use the keyboard to control the size: ctrl + direction key using System. componentModel; using System. drawing; using System. windows. forms; namespace AppGenCode. printer {public enum EnumAdjust {Nothing = 0, Size = 1, Postion = 2} public partial class AdjustTextBox: TextBox {public AdjustTextBox () {InitializeComponent (); InitCtrl ();} public AdjustTextBox (IConta Iner container) {container. add (this); InitializeComponent (); InitCtrl ();} private bool m_isMoving = false; private Point m_offset = new Point (0, 0); private Size m_intSize = new Size (0, 0); private EnumAdjust m_adjust = EnumAdjust. nothing; private int m_x, m_y, m_w, m_h = 0; private Rectangle RecAdjustSize {get {return new Rectangle (this. width-15, this. height-15, 15, 15) ;}} private Rectangle RecA DjustPostion {get {return new Rectangle (0, 0, this. width, this. height) ;}} private void InitCtrl () {this. text = "asdf1234"; this. multiline = true; this. borderStyle = BorderStyle. fixedSingle; this. readOnly = true;} # region mouse event protected override void OnMouseDown (MouseEventArgs e) {m_isMoving = true; m_offset = new Point (e. x, e. y); m_intSize.Width = this. width; m_intSize.Height = this. height; If (RecAdjustSize. contains (e. x, e. y) // adjust the size {this. cursor = Cursors. sizeNWSE; m_adjust = EnumAdjust. size;} else if (RecAdjustPostion. contains (e. x, e. y) // adjust the position {this. cursor = Cursors. sizeAll; m_adjust = EnumAdjust. postion;} else {m_adjust = EnumAdjust. nothing;} base. onMouseDown (e);} protected override void OnMouseUp (MouseEventArgs mevent) {Cursor = Cursors. default; m_isMoving = false; bas E. onMouseUp (mevent);} protected override void OnMouseMove (MouseEventArgs e) {CursorCtrl (e. x, e. y); m_x = this. left; m_y = this. top; m_w = this. width; m_h = this. height; if (m_isMoving) {switch (m_adjust) {case EnumAdjust. size: m_w = m_intSize.Width + (e. x-m_offset.X); m_h = m_intSize.Height + (e. y-m_offset.Y); break; case EnumAdjust. postion: m_x = Location. X + (e. x-m_offset.X); m_y = Loc Ation. Y + (e. y-m_offset.Y); break;} BackColor = Color. red; this. setBounds (m_x, m_y, m_w, m_h);} base. onMouseMove (e) ;}# endregion # region keyboard event protected override void OnPreviewKeyDown (PreviewKeyDownEventArgs e) {base. onPreviewKeyDown (e); if (e. alt) // adjust the size {switch (e. keyCode) {case Keys. left: this. width-= 5; break; case Keys. right: this. width + = 5; break; case Keys. down: this. height + = 5; B Reak; case Keys. up: this. height-= 5; break;} return;} if (e. control) {switch (e. keyCode) // adjust the position {case Keys. left: this. left-= 5; break; case Keys. right: this. left + = 5; break; case Keys. up: this. top-= 5; break; case Keys. down: this. top + = 5; break ;}}# endregion private void CursorCtrl (int x, int y) {if (! M_isMoving & RecAdjustSize. Contains (x, y) {this. Cursor = Cursors. SizeNWSE; return ;} this. Cursor = Cursors. Default ;}}}