
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I am trying to align the text in a text box to the right. I realize I can just set the text align property to the right on the form but I want to be able to do this in my code. The C# command is
textBox1.TextAlign = HorizontalAlignment.Right;
I have tried the following:
set txt-TOTAL-BALANCE::TextAlign to new type System.Windows.Forms.HorizontalAlignment
But this does not specify left, center or right. I have also tried
set txt-TOTAL-BALANCE::TextAlign to new type System.Windows.Forms.TextBox, TextAlign(Right)
But this code is incorrect and will not compile.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
The following works for me:
set textBox1::TextAlign to type System.Windows.Forms.HorizontalAlignment::Right
If you add the following namespace directive to the top of the program:
$set ilusing"System.Windows.Forms"
Then you can specify:
set textBox1::TextAlign to type HorizontalAlignment::Right

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
The following works for me:
set textBox1::TextAlign to type System.Windows.Forms.HorizontalAlignment::Right
If you add the following namespace directive to the top of the program:
$set ilusing"System.Windows.Forms"
Then you can specify:
set textBox1::TextAlign to type HorizontalAlignment::Right

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I originally had
set textBox1::TextAlign to NEW type System.Windows.Forms.HorizontalAlignment::Right
and I was getting an error because of the "NEW'
I took it out and set it like yours and it worked!
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
If you look at the MSDN docs for this here you will see that HorizontalAlignment is defined as an Enum and not a class. An enum is a value type which defines a set of constants so that you cannot instantiate it using the constructor New.
Documentation of an Enum type can be found here.
Instances of classes are created using the New
operator, which allocates memory for a new instance, invokes a constructor to initialize the instance, and returns a reference to the instance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
@Alex_Castro If I understand your intent, this might also work:
set txt-TOTAL-BALANCE::RightToLeft to type System.Windows.Forms.RightToLeft::Yes