Right Justify Textbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leonard

    #1

    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.
  • Brian Delahunty

    #2
    RE: Right Justify Textbox

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

    myTextBox.TextA lign = HorizontalAlign ment.Right;


    Hope this helps :-)

    Brian Delahunty
    Ireland




    "Leonard" wrote:
    [color=blue]
    > 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.[/color]

    Comment

    • Leonard

      #3
      RE: Right Justify Textbox

      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.

      [color=blue]
      >"Brian Delahunty" wrote:[/color]
      [color=blue]
      > Here's how to do it (assuming textbox is named myTextBox)
      >
      > myTextBox.TextA lign = HorizontalAlign ment.Right;
      >
      >
      > Hope this helps :-)
      >
      > Brian Delahunty
      > Ireland
      >
      > http://briandela.com/blog
      >
      >
      > "Leonard" wrote:
      >[color=green]
      > > 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.[/color][/color]

      Comment

      • Brian Delahunty

        #4
        RE: Right Justify Textbox

        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



        INDA SouthEast - http://southeast.developers.ie/ - The .NET usergroup I
        started in the southeast of Ireland.


        "Leonard" wrote:
        [color=blue]
        > 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.
        >
        >[color=green]
        > >"Brian Delahunty" wrote:[/color]
        >[color=green]
        > > Here's how to do it (assuming textbox is named myTextBox)
        > >
        > > myTextBox.TextA lign = HorizontalAlign ment.Right;
        > >
        > >
        > > Hope this helps :-)
        > >
        > > Brian Delahunty
        > > Ireland
        > >
        > > http://briandela.com/blog
        > >
        > >
        > > "Leonard" wrote:
        > >[color=darkred]
        > > > 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.[/color][/color][/color]

        Comment

        • Supra

          #5
          Re: Right Justify Textbox


          Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
          System.EventArg s) 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:
          [color=blue]
          >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.
          >
          >[/color]

          Comment

          • Supra

            #6
            Re: Right Justify Textbox

            asp doesn't have property alignment.
            Leonard wrote:
            [color=blue]
            >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.
            >
            >[/color]

            Comment

            • Leonard

              #7
              Re: Right Justify Textbox

              Hi Supra,
              Exactly what I needed.

              Thanks, Leonard

              "Supra" wrote:
              [color=blue]
              >
              > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
              > System.EventArg s) 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:
              >[color=green]
              > >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.
              > >
              > >[/color]
              >[/color]

              Comment

              Working...