根据其中的文本行数调整多行文本框的大小 [英] Resizing a multi line textbox according to number of lines of text inside it

查看:101
本文介绍了根据其中的文本行数调整多行文本框的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将多行文本框的大小调整为它包含的最小量?



我将文本流式传输到多行文本框中,并希望将此文本框保持为最小尺寸。根据用户的选择,它会有不同的大小,但会有一个恒定的文字大小。



我读取的文本框高度是根据文本大小计算的,而不是用户选择。它是如何将大小转换为像素的,这是最好的解决方法,还是有预先设定的功能来自动调整文本框?



|谢谢您的时间。

解决方案

您需要将设计视为一个整体。制作一些合理的尺寸并允许用户输入更多,然后会出现滚动条。这有什么问题?请记住,空间不是免费的。如果您为控件占用更多空间,则会以牺牲其他控件为代价。



毕竟,如果摘要显示太长,大多数不需要全部阅读,所以可用的小部分就足够了,那些想要全部阅读的人将宁愿同意使用滚动。您可以尝试使用真实文本来估算您需要的合理空间。



(顺便说一句,我学到了工业设计的黄金法则之一:如果你想要用一些文字呈现设计,为了测试的原型呈现,总是使用现实生活中的一些文本,尽可能真实。显示blah-blah或 Lorem ipsum 通常会错过很多。)



-SA

Is there a way to resize a multi line textbox to the minimum amount it contains?

I have text streamed into a multi line textbox and want to keep this textbox to a minimum size. It will be different sizes depending on user choices but will have a constant text size.

I read the textbox height is calculated from the text size, not user choice. How does it convert the size into pixels, and is this the best way of going about it or is there a premade function to autosize the textbox?

|Thank you for your time.

解决方案

You need to consider the design as a whole thing. Make some reasonable size and allow the user to enter more, then the scroll bar will appear. What''s wrong with that? Remember that the space does not come for free. If you take a bit more space for a control, it is taken at the expense of other controls.

After all, if a summary appears to be too long, most won''t need to read it all, so the available small part will suffice, and those who would want to read it all, will rather agree to use scrolling. You can experiment with real-life text to estimate the reasonable room you need.

(By the way, I learned one of the golden rules of industrial design: if you want to present the design with some text, for prototype presentation of testing, always use some texts from real life, as realistic as possible. People who show "blah-blah" or "Lorem ipsum" usually miss a lot.)

—SA


这篇关于根据其中的文本行数调整多行文本框的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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