469,360 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

Right Justify Textbox

How do I right justify input data in a textbox? I have some textboxes that
are used to input numbers, and I would like to right justify them.
Aug 10 '05 #1
6 9219
Here's how to do it (assuming textbox is named myTextBox)

myTextBox.TextAlign = HorizontalAlignment.Right;
Hope this helps :-)

Brian Delahunty
Ireland

http://briandela.com/blog
"Leonard" wrote:
How do I right justify input data in a textbox? I have some textboxes that
are used to input numbers, and I would like to right justify them.

Aug 10 '05 #2
Hi Brian,
I am using a textbox on a web application, and I also want to right
justify on some cells in a datagrid, while editing. The textbox doesn't
allow for TextAlign. I checked the help, and it looks like this may be for a
windows form. I thought there might be something under styles or controls,
but haven't been able to find anything.

"Brian Delahunty" wrote: Here's how to do it (assuming textbox is named myTextBox)

myTextBox.TextAlign = HorizontalAlignment.Right;
Hope this helps :-)

Brian Delahunty
Ireland

http://briandela.com/blog
"Leonard" wrote:
How do I right justify input data in a textbox? I have some textboxes that
are used to input numbers, and I would like to right justify them.

Aug 11 '05 #3
Ahok, sorry, I assumed it was Windows Forms.

Just do this for ASP.NET:

<asp:TextBox id="TextBox1" dir=rtl runat="server"></asp:TextBox>

I'm not sure if there is a programatic way to do this.

Hope that helps.

--
Brian Delahunty
Ireland

http://briandela.com/blog

INDA SouthEast - http://southeast.developers.ie/ - The .NET usergroup I
started in the southeast of Ireland.
"Leonard" wrote:
Hi Brian,
I am using a textbox on a web application, and I also want to right
justify on some cells in a datagrid, while editing. The textbox doesn't
allow for TextAlign. I checked the help, and it looks like this may be for a
windows form. I thought there might be something under styles or controls,
but haven't been able to find anything.

"Brian Delahunty" wrote:

Here's how to do it (assuming textbox is named myTextBox)

myTextBox.TextAlign = HorizontalAlignment.Right;
Hope this helps :-)

Brian Delahunty
Ireland

http://briandela.com/blog
"Leonard" wrote:
How do I right justify input data in a textbox? I have some textboxes that
are used to input numbers, and I would like to right justify them.

Aug 11 '05 #4

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim frm As Control = Me.FindControl("Form1")
Dim ctl As Control
For Each ctl In frm.Controls
If TypeOf ctl Is TextBox Then
DirectCast(ctl, TextBox).Style("TEXT-ALIGN") = "right"
End If
End Sub

u can changed left, center.
regards,

Leonard wrote:
How do I right justify input data in a textbox? I have some textboxes that
are used to input numbers, and I would like to right justify them.

Aug 14 '05 #5
asp doesn't have property alignment.
Leonard wrote:
How do I right justify input data in a textbox? I have some textboxes that
are used to input numbers, and I would like to right justify them.

Aug 14 '05 #6
Hi Supra,
Exactly what I needed.

Thanks, Leonard

"Supra" wrote:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim frm As Control = Me.FindControl("Form1")
Dim ctl As Control
For Each ctl In frm.Controls
If TypeOf ctl Is TextBox Then
DirectCast(ctl, TextBox).Style("TEXT-ALIGN") = "right"
End If
End Sub

u can changed left, center.
regards,

Leonard wrote:
How do I right justify input data in a textbox? I have some textboxes that
are used to input numbers, and I would like to right justify them.

Aug 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by David Holmes | last post: by
2 posts views Thread by jwatts | last post: by
2 posts views Thread by Tina | last post: by
2 posts views Thread by John Wilson | last post: by
8 posts views Thread by Leonard | last post: by
9 posts views Thread by JG | last post: by
5 posts views Thread by tshad | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.