Reputation: 2400
Here is my code:
if (r->Value == "Off"){
if (checkBox1->Checked)
checkBox1->Control::InvokeOnClick(checkBox1,EventArgs::Empty);
}
else if (r->Value == "Off") {
if (!checkBox1->Checked)
checkBox1->Control::InvokeOnClick(checkBox1,EventArgs::Empty);
}
and error:
1>c:\users\lukasz\desktop\project\General.h(2204): error C3767: 'System::Windows::Forms::Control::InvokeOnClick': candidate function(s) not accessible
1>c:\users\lukasz\desktop\project\General.h(2208): error C3767: 'System::Windows::Forms::Control::InvokeOnClick': candidate function(s) not accessible
What's wrong with it?
Upvotes: 0
Views: 297
Reputation: 942000
You are not getting the greatest compiler error message. But hard to blame it, you are maximizing the odds to confuse it hopelessly. You are supposed to use the name of a member after checkbox1->
. Instead you specified a class name, Control.
Do avoid looking for ways to click a control from your code, that's something the user does. The fact that InvokeOnClick isn't accessible is no accident. The intention here is to set the Checked property. So just set it:
if (r->Value == "Off") checkBox1->Checked = false;
else if (r->Value == "On") checkBox1->Checked = true;
with taking a guess at the original intent.
Upvotes: 2
Reputation: 8617
Well, Control
should be the name of a class to be able to call its static member functions by means of ::
, but it's apparently not a class. Either Control
is an object or a pointer to an object, I don't think you can use ::
with it. Just reasoning from the C++ perspective the question was (initially) tagged with.
Upvotes: 0