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


Copy Text


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;
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.