Update Settings After A Text Box Is Edited

Use the ‘Leave’ event

Locking the contents of a text box

ReadOnly = True
BackColour = Window (if you don’t want it greyed out)

Read the contents of a text box

String ^buffer;
buffer = txtScreenContents->Text;

Write to a text box

txtScreenContents->Text = “Hello World\r\nHeres another line.”

Multi lines

Use the \r\n characters to insert a line break.


	txtOutput->Text = "Name: " + dir->FullName + "\r\n";
	txtOutput->Text += "Created: " + CreationTime;

Scrolling text box


	txtHistory->SelectionStart = txtHistory->TextLength;	//Set cursor to end of the text box
	txtHistory->ScrollToCaret();				//Scroll the text box to the cursor position

Disable right click menu

Set shortcuts enabled property to false

Columns Of Text

Does the UseTabStops property work for text boxes?
UseCustomTabOffsets, CustomTabOffsets may be used for custom defined tab positions

Stopping The Contents Of A Text Box Being Selectable

See forms > Focus

Select All Of Text


	txtOutput->SelectAll();

Copy Text


	txtOutput->Copy();

Resizing To Fit The Text


	//Resize to fit the text
	System::Drawing::Size ^TextSize = TextRenderer::MeasureText(txtMyTextBox->Text, txtMyTextBox->Font);
	txtMyTextBox->Width = TextSize->Width;
	txtMyTextBox->Height = TextSize->Height;
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *