Change the Textbox height?

后端 未结 21 2269
心在旅途
心在旅途 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 07:50

    This is what worked nicely for me since all I wanted to do was set the height of the textbox. The property is Read-Only and the property is in the Unit class so you can't just set it. So I just created a new Unit and the constructor lets me set the height, then set the textbox to that unit instead.

    Unit height = txtTextBox.Height;
    double oldHeight = height.Value;
    double newHeight = height.Value + 20; //Added 20 pixels
    Unit newHeightUnit = new Unit(newHeight);
    txtTextBox.Height = newHeightUnit;
    

提交回复
热议问题