[**百分求教**]多行文本框问题!!!

挺拔的劲松 2007-05-12 10:31:52
多行文本框如何做到隐藏右边的滚动条,而变成文本框高度自动伸缩的样式。
也就是文本行数多文本框高度就高,行数少,高度就低。

这种效果,如何实现~???


在线等~~~
...全文
173 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
cqhq2008 2007-05-12
  • 打赏
  • 举报
回复
学习中!
withcsharp 2007-05-12
  • 打赏
  • 举报
回复
如果可以用 api
DT_CALCRECT + drawtext 是更准确的
withcsharp 2007-05-12
  • 打赏
  • 举报
回复
private void Form1_Load(object sender, EventArgs e)
{

// DT_CALCRECT

}

private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox1.Multiline = true;
if ( textBox1.Lines.Length<=1 )
{
textBox1.Height =8+ textBox1.Font.Height;
}
else
{
textBox1.Height =8+ (textBox1.Font.Height-2) * textBox1.Lines.Length + 1;
}
// DT_CALCRECT + drawtext
}
}
王集鹄 2007-05-12
  • 打赏
  • 举报
回复
//参考如下代码
// 思路是:在TextChanged事件中判断实际有多少行需要显示,然后乘上每行的高度加上边的宽度计算出来
// 通过EM_GETLINECOUNT消息得到事件行数,包括自动换行的情况

using System.Runtime.InteropServices;

[DllImport("User32.dll")]
static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
private const int EM_GETLINECOUNT = 0x00BA;
private void textBox1_TextChanged(object sender, EventArgs e)
{
int vCount = SendMessage(textBox1.Handle, EM_GETLINECOUNT, 0, 0);
textBox1.Height = (textBox1.Font.Height - 2) * vCount + 8;
}
hertcloud 2007-05-12
  • 打赏
  • 举报
回复
http://www.cnblogs.com/birdshome/archive/2004/12/29/83338.html
hertcloud 2007-05-12
  • 打赏
  • 举报
回复
asp.net 中

textboxID.Attributes.Add("style","width:100%;overflow:visible;")

挺拔的劲松 2007-05-12
  • 打赏
  • 举报
回复
楼上的,说一下如何控制??
chater 2007-05-12
  • 打赏
  • 举报
回复
用style控制
挺拔的劲松 2007-05-12
  • 打赏
  • 举报
回复
有没有知道的啊??或都给点思路也好啊~!!
CathySun118 2007-05-12
  • 打赏
  • 举报
回复
<textarea style="overflow: hidden"></textarea>

110,565

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧