WPF控件textBox多行输入设置

本文介绍如何使用TextWrapping、AcceptsReturn及VerticalScrollBarVisibility属性配置TextBox,使其支持多行输入并自动换行,同时添加垂直滚动条以适应内容长度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

将 TextWrapping 属性设置为 Wrap 会导致输入的文本在到达 TextBox 控件的边缘时换至新行,必要时会自动扩展 TextBox 控件以便为新行留出空间。

将 AcceptsReturn 属性设置为 true 会导致在按 Return 键时插入新行,必要时会再次自动扩展 TextBox 以便为新行留出空间。

VerticalScrollBarVisibility 属性向 TextBox 添加一个滚动条,以便在 TextBox 超出包含它的框架或窗口的大小时,可以滚动 TextBox 的内容。

 

<TextBox
  Name="tbMultiLine"
  TextWrapping="Wrap"
  AcceptsReturn="True"
  VerticalScrollBarVisibility="Visible"
>
  This TextBox will allow the user to enter multiple lines of text.  When the RETURN key is pressed, 
  or when typed text reaches the edge of the text box, a new line is automatically inserted.
</TextBox>

 


示例出处:http://blog.csdn.net/cryeyes/archive/2009/10/21/4707386.aspx

转载于:https://www.cnblogs.com/songhang520/p/5630657.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值