I have a wondering that if I write a specific word in a textBox in C++ .NET like for example the word:

"Name"

What I wonder here is that when writing this word it will turn to the color of blue when the word is written.
So if there is any function that in realtime when writing can recognice a word and if that word is written, this word will turn to a blue color.

I have found out that this syntax will "Select" the 10 first characters for a line in a textBox.
Perheps any approch in this direction could be used :)

textBox1->Select(1,10);

I have red the link through but dont think I will use something that complicated though I am not sure ofcourse : )

What I simply is trying to do is when I write a specific word in the textBox.
For example: "Street" , this word will turn to another color like blue.

So when I have written: "Stree" this word is still black until I write: "Street" wich then will be recogniced like a string and when this match, it change color to blue.

I dont know if it is possible to go through all words in a textbox each time you are typing a "letter" like an Application:: DoEvent in anyway and compare each word in the textbox with strings in the code and when a match is,
{
then begin turn this match/word blue ?
}

Just playing some idéas in my mind. (I know the code is not correct but just playing an idéa if an approach of this kind could be possible)

string Word == "Street";


If (textBox1->Text = Word) 
{
     Word = NewColor(Word, Color::Blue)
}

You need to do customized drawing for the Textbox. It can be difficult/complex to implement, depending on what you want to do. Anyhow, if you are interested, then look e.g. into
http://msdn2.microsoft.com/en-us/magazine/cc164019.aspx

If I write the code "Street" with this code in the textBox. It change the color of "Street" to blue when it is written. Though this code do Select the word and then deselect all wich sets the cursor at the beginning of the textBox wich it shouldn´t.

It also paints everything in the textBox blue since "Street" is a part of it.

String^ word = "Street";

if( textBox1->Text == word )
{
	 this->textBox1->Select(0, 10);

this->textBox1->SelectionColor = Color::Blue;
this->textBox1->DeselectAll();
}

If you add an TextChanged handler to your form, you can change the color of the TextBox's (whole) text as follows:

if(textBox1->Text == "red")
{
    textBox1->ForeColor = System::Drawing::Color::Red;
}
else if(textBox1->Text == "blue")
{
    textBox1->ForeColor = System::Drawing::Color::Blue;
}
else
{
    textBox1->ForeColor = System::Drawing::Color::Black;
}

I'm not sure what you are targeting, but you could of course search the textbox's current text for something in your handler, and then make changes to the text color accordingly.

Thanks, it was not really what I had in mind. Anyway I think I have a solution in mind through searching each line and recognice words this way.

I might open a new thread for this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.