Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DarkTextBoxScroll : Control
- {
- private static TextBox textBox = new TextBox();
- public DarkTextBoxScroll()
- {
- Paint += UserControl1_Paint;
- Resize += UserControl1_Resize;
- textBox.Multiline = true;
- textBox.BorderStyle = BorderStyle.None;
- Controls.Add(textBox);
- textBox.BackColor = Color.FromArgb(22, 22, 22);
- textBox.ForeColor = Color.White;
- }
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
- private const int WM_VSCROLL = 0x115;
- private const int SB_BOTTOM = 7;
- /// <summary>
- /// Scrolls the vertical scroll bar of a multi-line text box to the bottom.
- /// </summary>
- /// <param name="tb">The text box to scroll</param>
- public static void ScrollToBottom(TextBox tb)
- {
- SendMessage(tb.Handle, WM_VSCROLL, (IntPtr)SB_BOTTOM, IntPtr.Zero);
- }
- /// <summary>
- /// Use this method to scroll the textbox down to the bottom.
- /// </summary>
- public static void Scroll()
- {
- ScrollToBottom(textBox);
- }
- /// <summary>
- /// The text property.
- /// </summary>
- public override string Text
- {
- get { return textBox.Text; }
- set { textBox.Text = value; }
- }
- /// <summary>
- /// The TextChanged event.
- /// </summary>
- [Browsable(true)]
- public new event EventHandler TextChanged
- {
- add
- {
- textBox.TextChanged += value;
- }
- remove
- {
- textBox.TextChanged -= value;
- }
- }
- /// <summary>
- /// When you resize the control.
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void UserControl1_Resize(object sender, EventArgs e)
- {
- textBox.Size = new Size(Width - 3, Height - 2);
- textBox.Location = new Point(2, 1);
- }
- /// <summary>
- /// Paint the user control.
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void UserControl1_Paint(object sender, PaintEventArgs e)
- {
- // Let's draw a rectangle around the control.
- ControlPaint.DrawBorder(e.Graphics, ClientRectangle, Color.FromArgb(255, 44, 44, 44), ButtonBorderStyle.Solid);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement