TextAlign in TextBox

I have found some issue in the textbox,after i install the VS 2005 sevice pack 1 and NETCF 2 Service pack 1.

The texAlign only show "Left" . Please help out!



Answer this question

TextAlign in TextBox

  • bhaskar27in

    Dan Elliott,
    the method works great!

    regards
    mario



  • KAAU

    The inability to specify alignment in a single-line text box is a limitation of the underlying Windows CE text box control. There is a work-around however:

    1. To allow textbox alignment to be set, set the textbox's Multiline property to true.
    2. To keep text on a single line in a multiline textbox:
      1. Set the form's KeyPreview property to true. This will route keys to the form prior to sending them to the control.
      2. Add a handler for the form's KeyUp event. In this handler, disallow the enter key if the textbox has focus. This will keep text in the textbox on a single line.


    private void Form1_KeyUp(object sender, KeyEventArgs e)
    {
    if (this.textBox1.Focused && e.KeyCode == Keys.Enter)
    {
    e.Handled = true;
    }
    }


    HTH
    Dan

  • tattoo

    Hi Bright angel,
    This has nothing to do with installing VS2005 or .NetCF2 Servic Pack1.
    the text alignment of the standard text box, in smart device development, is always "Left".
    gl
    mario



  • RufusLDK

    Maybe it is the same behavior as in VS 2003. There you have first to enable the Multiline property to align the text. Hope this works also in VS 2005.

  • TextAlign in TextBox