public UpDownBase() { _UpDownAlign = LeftRightAlignment.Right; InternalBorderStyle = BorderStyle.None; spnSpinner = new UpDownStepper(); spnSpinner.Offset = new Size(-1, -1); spnSpinner.UpButton += (sender, e) => { UpButton(); }; spnSpinner.DownButton += (sender, e) => { DownButton(); }; txtView = new UpDownTextBox(this); txtView.ModifiedChanged += OnChanged; txtView.AcceptsReturn = true; txtView.AutoSize = false; txtView.BorderStyle = BorderStyle.Fixed3D; txtView.TabIndex = TabIndex; txtView.SetStyle(ControlStyles.Selectable, true); spnSpinner.Size = spnSpinner.PreferredSize; spnSpinner.Dock = DockStyle.Right; txtView.Dock = DockStyle.Left; SuspendLayout(); Controls.Add(spnSpinner); Controls.Add(txtView); ResumeLayout(); SuspendLayout(); txtView.Size = new Size(Width - spnSpinner.Width - 4, txtView.PreferredHeight); txtView.Anchor = AnchorStyles.Left | AnchorStyles.Right; spnSpinner.Size = spnSpinner.PreferredSize; spnSpinner.Anchor = AnchorStyles.Right; ResumeLayout(); Height = PreferredHeight; TabIndexChanged += TabIndexChangedHandler; txtView.KeyDown += OnTextBoxKeyDown; txtView.KeyPress += OnTextBoxKeyPress; // txtView.LostFocus += OnTextBoxLostFocus; txtView.Resize += OnTextBoxResize; txtView.TextChanged += OnTextBoxTextChanged; // So the child controls don't get auto selected when the updown is selected auto_select_child = false; SetStyle(ControlStyles.FixedHeight | ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.StandardClick | ControlStyles.UseTextForAccessibility, false); SetStyle(ControlStyles.SupportsTransparentBackColor, true); base.BackColor = Color.Transparent; }
public UpDownBase() { _UpDownAlign = LeftRightAlignment.Right; InternalBorderStyle = BorderStyle.Fixed3D; spnSpinner = new UpDownStepper(this); txtView = new UpDownTextBox(this); txtView.ModifiedChanged += new EventHandler(OnChanged); txtView.AcceptsReturn = true; txtView.AutoSize = false; txtView.BorderStyle = BorderStyle.None; txtView.Location = new System.Drawing.Point(17, 17); txtView.TabIndex = TabIndex; spnSpinner.Width = 16; spnSpinner.Dock = DockStyle.Right; txtView.Dock = DockStyle.Fill; SuspendLayout(); Controls.Add(spnSpinner); Controls.Add(txtView); ResumeLayout(); SuspendLayout(); txtView.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; txtView.Size = new Size(txtView.Width - spnSpinner.Width, txtView.Height); ResumeLayout(); Height = PreferredHeight; base.BackColor = txtView.BackColor; TabIndexChanged += new EventHandler(TabIndexChangedHandler); txtView.KeyDown += new KeyEventHandler(OnTextBoxKeyDown); txtView.KeyPress += new KeyPressEventHandler(OnTextBoxKeyPress); // txtView.LostFocus += new EventHandler(OnTextBoxLostFocus); txtView.Resize += new EventHandler(OnTextBoxResize); txtView.TextChanged += new EventHandler(OnTextBoxTextChanged); // So the child controls don't get auto selected when the updown is selected auto_select_child = false; SetStyle(ControlStyles.FixedHeight, true); SetStyle(ControlStyles.Selectable, true); SetStyle(ControlStyles.Opaque | ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.StandardClick | ControlStyles.UseTextForAccessibility, false); }