文字高度问题 [英] text height problem
问题描述
我有一个接受文字输入的多行文本框,我希望它可以根据它所持有的文字来调整它的高度,所以我使用a
SendMessage API获取文本的行数,然后将
TextBox.Height设置为(linecount * font.Height),但是有一些东西
这个计算错了,文本框总是大于
文本行,有什么想法吗?
谢谢。
你好Liups,
要获得文本框的行数,你不需要Api,那就是完整的
托管代码支持
。
但是文本框中的行是由回车关闭的行
(CR)。
(要在文本框中获取行数,我不知道托管代码)。
这可能是问题吗?
Cor
我有一个接受文字输入的多行文本框,我希望它根据它所持有的文本来调整它的高度,所以我使用一个
SendMessage API来获取文本的行数,然后将
TextBox.Height设置为(linecount * font.Height),但这个计算有问题,文本框总是比
文本行大,有什么想法吗?
>
我的意思是行数由换行计算,而不是由crlfs分隔的行。
2004年1月31日星期六09:54:12 + 0100,Cor < no*@non.com>写道:
你好Liups,
要获得文本框的行数,你不需要Api,这是完整的
支持托管代码。
但是文本框中的行是由回车关闭的行
(CR)。
(要在文本框中获取行数我不知道托管代码。
这可能是问题吗?
我有一个接受文本输入的多行文本框,我希望它根据它保存的文本调整其高度,所以我使用一个
SendMessage API来获取文本的行数,然后设置
TextBox.Height to(linecount * font.Height),但是这个计算有一些错误,文本框总是比
文本行大,有什么想法吗?
* liups< Ge ***** @ Spammers.com> scripsit:我有一个接受文本输入的多行文本框,我希望它根据它保存的文本调整高度,所以我使用了一个
SendMessage API获取文本的行数,然后将
TextBox.Height设置为(linecount * font.Height),但这个计算有一些错误,文本框总是大于
文本行,任何想法?
您可以使用''Graphics.MeasureString''来获取字符串的大小
(大约)。
-
Herfried K. Wagner [MVP]
< http://www.mvps。 org / dotnet>
Hi,
I have a multi-line textbox that accepts text input, I want it to
adjust its height according to the text it holds, so I use a
SendMessage API to get the line count of the text, then set the
TextBox.Height to (linecount * font.Height), but there is something
wrong with this calculation, the textbox is always larger than the
text lines, any ideas?
Thank you.
Hi Liups,
To get the line count of a textbox you do not need an Api, that is full
supported with managed code.
But with lines in a textbox is ment a line closed by a carriage return
(CR).
(To get the row count in a textbox I do not know managed code).
Is that maybe the problem?
Cor
Hi,
I have a multi-line textbox that accepts text input, I want it to
adjust its height according to the text it holds, so I use a
SendMessage API to get the line count of the text, then set the
TextBox.Height to (linecount * font.Height), but there is something
wrong with this calculation, the textbox is always larger than the
text lines, any ideas?
I mean the line counts by wrap, not lines seperated by crlfs.
On Sat, 31 Jan 2004 09:54:12 +0100, "Cor" <no*@non.com> wrote:
Hi Liups,
To get the line count of a textbox you do not need an Api, that is full
supported with managed code.
But with lines in a textbox is ment a line closed by a carriage return
(CR).
(To get the row count in a textbox I do not know managed code).
Is that maybe the problem?
CorHi,
I have a multi-line textbox that accepts text input, I want it to
adjust its height according to the text it holds, so I use a
SendMessage API to get the line count of the text, then set the
TextBox.Height to (linecount * font.Height), but there is something
wrong with this calculation, the textbox is always larger than the
text lines, any ideas?
* liups <Ge*****@Spammers.com> scripsit:I have a multi-line textbox that accepts text input, I want it to
adjust its height according to the text it holds, so I use a
SendMessage API to get the line count of the text, then set the
TextBox.Height to (linecount * font.Height), but there is something
wrong with this calculation, the textbox is always larger than the
text lines, any ideas?
You can use ''Graphics.MeasureString'' to get the size of the string
(approximately).
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
这篇关于文字高度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!