3

I have a Windows.Forms.TextBox with TextAlign = HorizontalAlignment.Right. This works when the text is short enough, however when the text is too long to fit in the box, the alignment appears to revert to left-aligned.

The text is an automatically generated filename where, for UX purposes, the end of the string is more meaningful than the beginning, therefore it's better to crop off the start than the end.

How can I make the TextBox always align its text to the right margin, even if the text is too long for the text box?

damian
  • 3,604
  • 1
  • 27
  • 46
  • 1
    I see the mentioned behaviour, mind saying why you need the text to align right when it is clipping due to too long text (example) please? – Bernd Linde Apr 01 '15 at 09:53
  • Thanks, question has been edited. – damian Apr 01 '15 at 10:07
  • Have a look at this [answer](http://stackoverflow.com/questions/898307), the method explained there to move the caret to the end works, even when not focusing the control. But you will need to prevent the automatic movement of the caret when a user is typing in the textbox. – Bernd Linde Apr 01 '15 at 10:21

1 Answers1

-1

first answer might be to use the substring method via code and the put it on the TextBox. Second answer migth be to change the TextBox to multiple Lines so that you can see all the path. Hope it helps.

Gino
  • 175
  • 3
  • 16