I do not think you can do this out of the box. But there are two ways that I can think with which you can achieve your goal.
- You really need a
TextBox control. Can Label work for you. If so, then Label does not have the problem described above. If not, you can use a great trick to always display your content in Label and switch it to TextBox when the user starts typing. - Another way is to disable scrolling in the TextBox. Adjust the height of the
TextBox to 3 clearly visible lines. Now drop this TextBox in the Panel . Make sure Panel uses Panel.AutoScroll = true (you can use a separate VerticalScrollbar or HorizontalScrollbar or both, if you need more control). Now adjust Panel.Height so that only two full lines are visible, and the 3rd line is partially visible.
You mentioned that your TextBox
may contain a variable number of rows
But you also mentioned
I want the text fields to correspond to two lines, plus the tax in them, so that only the top of the third line is displayed.
So I'm not sure what the matter is. If you need to dynamically adjust the height of your TextBox , look at this message in Manage Autoresize Text Box Vertically
source share