Change the Textbox height?

后端 未结 21 2249
心在旅途
心在旅途 2020-12-09 07:24

How do I change the height of a textbox ?

Neither of the below work:

this.TextBox1.Size = new System.Drawing.Size(173, 100);
         


        
21条回答
  •  盖世英雄少女心
    2020-12-09 08:10

    You can put it inside a panel that has the same back color with your desired height. This way has this advantage that the text box can center horizontally, which is not provided by other solutions.

    You can make it even more natural by using the following methods

        private void textBox1_Enter(object sender, EventArgs e)
        {
    
            panelTextBox.BorderStyle = BorderStyle.FixedSingle;
        }
    
        private void textBox1_Leave(object sender, EventArgs e)
        {
            panelTextBox.BorderStyle = BorderStyle.None;
        }
    

提交回复
热议问题