Jump to content

Text box alignment with long string

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Peckerfish

Peckerfish

    Newbie

  • Members
  • Pip
  • 8 posts
I've created a Text box using default settings. The code for getting the text is...

string connCodeUDL1 = "";

beam1.GetUserProperty("CONN_CODE_UDL1", ref connCodeUDL1);

textBoxConnCode1.SelectedText = connCodeUDL1;

The textbox is 10 characters long. My problem is when the connCodeUDL1 string is over 10 characters long, say 15. It displays the furthest right characters only (I can mouse drag to see the first 5 chars). I want it show the first 10 characters of the string always.

Any help would be appreciated.

#2
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Please use CODE tags.

To achieve this, simply use code to set the TextBox's SelectionStart property to 0, and call ScrollToCaret():

textBoxConnCode1.SelectionStart = 0;
textBoxConnCode1.ScrollToCaret();

Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#3
Peckerfish

Peckerfish

    Newbie

  • Members
  • Pip
  • 8 posts
Thank you Xav that worked well :)

#4
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Anytime, my friend. ;)
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums