Multi Line TextBox text alignment (C# 2.0)

半世苍凉 提交于 2019-12-20 04:24:13

问题


I have Multi Line TextBox (C# 2.0). I want to display some data as follows.

"Contact Person    : "  + string1 + Environment.NewLine
"Sales Man         : "  + string2 + Environment.NewLine
"Credit Limit      : "  + string3 + Environment.NewLine
"Due days          : "  + string4 + Environment.NewLine

But this code displaying as

Contact Person    :   Person1
Sales Man        :   salesman1
Credit Limit :  50000.00 
Due days       : 20

My problem is I can't align the text. My expected out put,

Contact Person    : Person1
Sales Man         : salesman1
Credit Limit      : 50000.00 
Due days          : 20 

How can I achieve this?


回答1:


You need to change the font used by the textbox to a monospaced (non-proportional) font, like Courier.




回答2:


Set the AcceptsTab property of your textBox to true. Then use '\t' in your textlines to tab to the correct position.



来源:https://stackoverflow.com/questions/1303938/multi-line-textbox-text-alignment-c-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!