Compiler Error C2659

For my program, im making a highlighter rich text box. Its a multy-tab programers editor. Since I have to define my rich text boxes at realtime, I decided to create a class that automaticaly sets all default settings and allows easy changing (font, color, highlighter, events, etc).

Everything works fine, except when I try to define event functions. The code I entered is a replica of what VCPP .Net generates when assigning functions via the visual interface, changed to fit my context, but it complains that im trying to set a value to a function.
[code]

using namespace System;

using namespace System::Windows::Forms;

ref class HighlighterTextBox

{

public:

HighlighterTextBox(RichTextBox^richtextbox)

{

this->textbox=richtextbox;

this->textbox->OnTextChanged+=gcnew System::EventHandler(this,&HighlighterTextBox::Highlight);

}

private:

System::Windows::Forms::RichTextBox^textbox;

System::Void Highlight(System::Object^sender,System::EventArgs^e)

{

// Highlighting occures here

}

};

[/code]I have absolutly no clue what im suppose to do to fix this...

Please help me :S

[1204 byte] By [DrDeath] at [2007-12-25]
# 1

this->textbox->OnTextChanged+=gcnew System::EventHandler(this,&HighlighterTextBox::Highlight);

This is most likely the line which is causing you the problem. The event for text changed is TextBox::TextChanged.

To add it in C++/CLI it is.

this->textbox->TextChanged += gcnew System::EventHandler(this, &HighlighterTextBox::Highlight);

crescens2k at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual C++ 2005 Express Edition...
# 2
Couldnt continue working on my program for over a week because I put OnTextChanged instead of TextChanged

Thank you so much XD

DrDeath at 2007-8-31 > top of Msdn Tech,Visual Studio Express Editions,Visual C++ 2005 Express Edition...