Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error C2039: 'Dispose' : is not a member of 'System::Windows::Forms::ErrorProvider'

I am trying to use ErrorProvider Class to show error on checkbox. I am able to show the error using the following code

errorProvider1->SetError(checkBox1,"Error");

But when I am trying to dispose this errorProvider using the following code

errorProvider1->Dispose();

Then this line is showing error

error C2039: 'Dispose' : is not a member of 'System::Windows::Forms::ErrorProvider'

This Code I am able to run successfully in vc# but not in vc++;

But since My requirement is to use this in vc++.

Can anybody please tell me what is the problem in this code.

Thanks in Advance

like image 998
Mayank Prabhakar Avatar asked Jul 11 '12 12:07

Mayank Prabhakar


1 Answers

According to this article, the IDisposable pattern is different in C++/CLI, and you cannot implement or call Dispose() methods in that language.

You have to use the delete operator instead:

errorProvider1->SetError(checkBox1,"Error");
delete errorProvider1;  // Equivalent to errorProvider1->Dispose().
like image 129
Frédéric Hamidi Avatar answered Oct 03 '22 09:10

Frédéric Hamidi