TrackBar 'Validating' Event Hander doesn't match Delegate?

S

Steve N.

I am trying to add a 'Validating' event handler to a TrackBar.

Code:
...
this->tbKeyboards->Validating += new System::EventHandler(this,
tbKeyboards_Validating);
...
System::Void tbKeyboards_Validating(Object* sender,
System::ComponentModel::CancelEventArgs* e)
...

Compiling this code results in the following error: "void
kbKeyboards_Validating(System::Object __gc
*,System::ComponentModel::CancelEventArgs __gc *)' : the specified
function does not match the delegate type 'void (System::Object __gc
*,System::EventArgs __gc *)"

So I change the 'System::ComponentModel::CancelEventArgs' to
'System::EventArgs' in order to fix it. (It doesn't seem to make sense
because what is the use of a Validating event if there is no
cancelEventArgs?) Anyway, changing it gives me this error:
"'System::Windows::Forms::Control::add_Validating' : cannot convert
parameter 1 from 'System::EventHandler __gc *' to
'System::ComponentModel::CancelEventHandler __gc *'"

So what's wrong?

Thanks.
 
S

Steve N.

It would probably help if I posted the function code (oops):

// First Way
private: System::Void tbKeyboards_Validating(Object* sender,
System::ComponentModel::CancelEventArgs* e) { }

// Second Way
private: System::Void tbKeyboards_Validating(Object* sender,
System::EventArgs* e) { }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top