TextBox String/Text's Padding For Custom Control

前端 未结 2 746
隐瞒了意图╮
隐瞒了意图╮ 2021-01-14 13:16

I\'m a newbie, and recently I\'ve asked this question, where it taught me to have my best option for TextBox\'s bottom border, that prevents flickering/tearing - resulted by

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-14 14:05

    I think you will have to inherit from UserControl rather than from TextBox and add a TextBox to your UserControl. Code below is by no means complete but should show you what I'm talking about

    public partial class TextBoxMaterial : UserControl
    {
        public TextBoxMaterial()
        {
            InitializeComponent();
    
            this.Controls.Add(new Label()
            {
                Height = 2,
                Dock = DockStyle.Bottom,
                BackColor = Color.Gray,
            });
    
            this.Controls.Add(new TextBox()
            {
                Left = 10,
                Width = this.Width - 20,
                BackColor = this.BackColor,
                BorderStyle = BorderStyle.None,
             });
        }
    }
    

提交回复
热议问题