我们如何在Windows窗体C#中运行时拖动鼠标来更改文本框或标签的宽度 [英] How we change the width of Text box or label with mouse dragging at runtime in windows forms C#

查看:424
本文介绍了我们如何在Windows窗体C#中运行时拖动鼠标来更改文本框或标签的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I want a re sizable text box in windows application. If text more then text box area then user can increase the width of textbox using mouse. 
Text box width only changeable from right side of the text box

推荐答案

您必须处理mousedown,mousedrag和mouseup事件,跟踪鼠标移动,然后将重新调整大小的调用分配给UI以相应地设置文本框宽度。
You have to handle mousedown, mousedrag and mouseup events, to trace mouse movements and then dispatch re-size calls to UI to set textbox width accordingly.


与解决方案3中建议的方法完全相同我们如何在Windows中移动标签鼠标单击它时以及当鼠标键向上然后停止在组框内移动时形成的结构 [ ^ ]



只接受TextBox而不是Label。
In exactly the same way as you were advised in Solution 3 to your earlier question How we move a label in windows forms when mouse click on it and when mouse key up then stop moving inside a group box[^]

Just inherit from TextBox instead of Label.


这篇关于我们如何在Windows窗体C#中运行时拖动鼠标来更改文本框或标签的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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