Results 1 to 2 of 2

Thread: Text Alignment

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2012
    Posts
    41

    Question Text Alignment

    Hello!
    I want to seperate a line in a textbox, so that one part is aligned to the right and the other to the left.
    I tried to do this by first:
    - using TextBox1.Select(something,something)
    ' this selected the text I wanted to align to the right

    - TextBox1.SelectionAlignment = HorizontalAlignment.Right
    'but this aligns the whole row to the right.

    Is there a way for text to be aligned in 2 ways in a row?
    Sort of
    like this

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Text Alignment

    Quote Originally Posted by suzi9spal View Post
    Hello!
    I want to seperate a line in a textbox, so that one part is aligned to the right and the other to the left.
    I tried to do this by first:
    - using TextBox1.Select(something,something)
    ' this selected the text I wanted to align to the right

    - TextBox1.SelectionAlignment = HorizontalAlignment.Right
    'but this aligns the whole row to the right.

    Is there a way for text to be aligned in 2 ways in a row?
    Sort of
    like this
    The short answer is no. TextBox has only one horizontal alignment property and it applies to all the text.

    The simplest way to make more complicated layouts is to use a container control like a Panel or a UserControl. For example, you could take a panel and place two text boxes or labels at the top, one on the left with the text aligned left, and the other on the right with the text aligned right. If these are intended as headings for a page, you could add another textbox beneath them to contain the rest of the text. To print the resulting layout, you could use the DrawToBitmap method of the container control, which will render it to a bitmap complete with the child controls.

    BB

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width