窗体形式文本框文本对齐 [英] windows form text box text alignment

查看:137
本文介绍了窗体形式文本框文本对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体文本框和一个浏览按钮。当我点击浏览按钮时弹出文件夹选择对话框,我可以选择一个文件夹,它将显示在文本框中



假设我的完整文件夹路径是答:/ somefolder / subfolder1 / subfolder2



我的文本框内容如下



答:/ somefolder / subfolder1 / su



但我希望我的文本框看起来像



old / subfolder1 /子文件夹2



提前致谢。

I have a windows form textbox and a browse button. when i clicks the browse button a folder selection dialog pops up and iam able to select a folder which will be shown in the text box

suppose my full folder path is "A:/somefolder/subfolder1/subfolder2"

My text box content is like

A:/somefolder/subfolder1/su

But i want my text box to look like

older/subfolder1/subfolder2

Thanks in advance.

推荐答案

TextAlign 属性看起来会满足您的要求。



The TextAlign property looks like it will satisfy your requirement.

txtFolderName.TextAlign = HorizontalAlignment.Right 


试试这个:



Try this:




yourTextBox.SelectionStart = yourTextBox.TextLength;




yourTextBox.SelectionStart = yourTextBox.TextLength








希望这会有所帮助。



Hope this helps.


这篇关于窗体形式文本框文本对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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