C# Resize textbox to fit content

前端 未结 10 716
礼貌的吻别
礼貌的吻别 2020-12-05 13:39

I\'m writing a program where the user should be able to write text in a textbox. I\'d like the textbox to resize itself, so it fit the content. I\'ve tried the following:

10条回答
  •  不知归路
    2020-12-05 14:13

    You will need to use the CreateGraphics() method of the form to create the Graphics instance to measure the string on.

    The TextChangedEventArgs class does not have a Graphics property, that is a property of the PaintEventArgs class passed in to the Paint event handler

提交回复
热议问题