右对齐特定文本 [英] Right align a particular text

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

问题描述





我可以直接对齐像A这样的特殊文字/单词吗?



谢谢

解决方案

您可以申请:



 < span class =code-keyword><   asp:textbox     id   =  txtTest   样式  =  text- align:right;    runat   =   server    xmlns:asp   = #unknown >  <   / asp:textbox  >  





这个词可以是任何可以用于两者的数字或字符。


作为一个WinForms替代解决方案2

 Me.TextBox1.TextAlign = Horizo​​ntalAlignment.Right 

Karen Mitchelle [ ^ ]在评论中指出,您可以在设计时更改此属性。



ASP代码隐藏或winforms ...



如果文本用于其他目的,你可以通过左边用空格填充右对齐字符串本身例如

 Dim s As String =Some Text.PadLeft(15,)

产生

 |一些文字| 



例如,您可以使用此方法右对齐组合框中的项目,例如

 对于 i =  1    10  
.ComboBox1.Items.Add(i.ToString()。PadLeft( 15 ))
下一步


Hi,

Ho can I just right align a special text/word like "A"?

Thanks

解决方案

You can apply :

<asp:textbox id="txtTest" style="text-align: right;" runat="server" xmlns:asp="#unknown"></asp:textbox>



The word can any thing a number or character it will work for both.


As a WinForms alternative to Solution 2

Me.TextBox1.TextAlign = HorizontalAlignment.Right

or as Karen Mitchelle [^] pointed out in the comments, you can change this property at design time.

For either ASP code-behind or winforms...

If the text is to be used for other purposes you can "right-align" the string itself by padding left with spaces e.g.

Dim s As String = "Some Text".PadLeft(15, " ")

produces

|      Some Text|


For example you could use this method to right align items in a combobox like this

For i = 1 To 10
        Me.ComboBox1.Items.Add(i.ToString().PadLeft(15, " "))
Next


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

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