文本框在给出输入字符串时自动调整大小 [英] Textbox automatic sizing on giving input string

查看:89
本文介绍了文本框在给出输入字符串时自动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个具有文本框的用户控件。

此用户控件在运行时放在表单中。这个表单给用户控件一个字符串,文本框用多行显示。(我这样做是使用一个属性来设置文本框的文本属性)

所以在设计师视图中将multiline属性设置为TRUE并将word wrap属性设置为TRUE。

这样可以在运行时以多行显示文本。

但是文本框大小不会根据它包含的文本行数增长。

我不想使用滚动条。

请建议如何设置大小文本框的大小根据它在运行时的行数进行调整。这样就显示了所有的线条。我可以相应地在它下面放置其他控制。


谢谢

Hi,

I have a user control that has a textbox.
This user control is placed in a form at runtime. This form gives a string to the user control and the textbox is to show this in multiple lines.(i do so using a property to set the textbox''s text property)
So in designer view i set the multiline property to TRUE and
the word wrap property to TRUE.
This enables the text to be shown in multiple lines at runtime.
But the textbox size does not grow according to the number of lines of text that it contains.
I dont want to use scrolls.
Please suggest how to set the size of the textbox to adjust according to the number of lines it has at runtime. So that all lines are shown. and i can accordingly place other contols below it.

Thanks

推荐答案





我有一个具有文本框的用户控件。

此用户控件在运行时放在表单中。这个表单给用户控件一个字符串,文本框用多行显示。(我这样做是使用一个属性来设置文本框的文本属性)

所以在设计师视图中将multiline属性设置为TRUE并将word wrap属性设置为TRUE。

这样可以在运行时以多行显示文本。

但是文本框大小不会根据它包含的文本行数增长。

我不想使用滚动条。

请建议如何设置大小文本框的大小根据它在运行时的行数进行调整。这样就显示了所有的线条。我可以相应地在它下面放置其他控制。


谢谢
Hi,

I have a user control that has a textbox.
This user control is placed in a form at runtime. This form gives a string to the user control and the textbox is to show this in multiple lines.(i do so using a property to set the textbox''s text property)
So in designer view i set the multiline property to TRUE and
the word wrap property to TRUE.
This enables the text to be shown in multiple lines at runtime.
But the textbox size does not grow according to the number of lines of text that it contains.
I dont want to use scrolls.
Please suggest how to set the size of the textbox to adjust according to the number of lines it has at runtime. So that all lines are shown. and i can accordingly place other contols below it.

Thanks



你可以计算到达它的字符数文本框的边缘,并根据输入的字符数量调整文本框的大小。干杯。

You can calculate the number of characters that will reach the textbox''s edge and resize the textbox according to the number of entered characters. Cheers.



您可以计算到达文本框边缘的字符数,并根据文本框的数量调整文本框的大小。输入字符。干杯。
You can calculate the number of characters that will reach the textbox''s edge and resize the textbox according to the number of entered characters. Cheers.



嗨Vanc


感谢您的回复。

基本上在设计师视图中,我的文本框只是适合一行字符串。

在运行时它可以得到一个非常长的字符串。

因此,当Multiline为真时,文本的其余部分会出现在下一行中,等等。

但不幸的是我的文本框大小保持不变。

我需要它在运行时使用行数增加(垂直)。

我不想使用滚动条。

你可以建议如何解决这个问题。

最好的方法是知道一行中可以容纳多少个字符,然后将总字符数除以它,以了解行数。然后多次调整大小?

或者更好地使用标签代替。我永远不必接受用户输入。我只需要在运行时以多行显示字符串。


非常感谢。真的很感谢你的帮助。

Karan

Hi Vanc

Thanks for replying.
Basically In designer view, My textbox just fits in one line of string.
At runtime it could get a very long string.
Thus as Multiline is true, the rest of the text comes in the next line and so on.
But unfortunetely my textbox size remains the same.
I need it to grow(vertically) with the numbers of line at runtime.
I dont want to use scroll bars.
could u please suggest how to go about this.
Is the best way to know how many characters can fit in a single line and then divide total characters by that, to know the number of lines. and then resize by that many times?
or is it better to use a label instead. i never have to take user input. i just need to display the string at runtime in multiple lines.

Thanks alot. really appreciate your help.
Karan


按照建议,计算你所拥有的字符串中的字符数,除以广泛允许的字符数。文本框(它是一个属性,您可以设置它)并确定使文本框显示的行数。
As was suggested, compute the number of characters in the string you have, divide by the number of allowable characters wide in the textbox (it''s a property, you can set it) and determine how many rows to make your textbox show.


这篇关于文本框在给出输入字符串时自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆