Click here to Skip to main content
11,805,316 members (66,156 online)
Rate this: bad
Please Sign up or sign in to vote.
I need to send some data from Form7 to From1.
In Form7 you eneter text in textbox and click button ok
when Form1 load it will show text from Form7 in one lalbel called class_name_lbl..
Here is code for FORM7:

private: String^ class_name()
                return textBox1->Text;
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

Here is code for FORM1

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
             Form7^ forma = gcnew Form7();
             class_name_lbl->Text = forma->class_name();

But this code won't work, here is eror in line: " class_name_lbl->Text = forma->class_name();"

and eror is:
Error   5   error C3767: 'Klaser::Form7::class_name': candidate function(s) not accessible   d:\maturski\klaser\klaser\Form1.h   1887

Can anyone help, and tell me how to solve this eror..?
Posted 21-Apr-13 4:46am
Edited 21-Apr-13 5:18am
ThePhantomUpvoter at 21-Apr-13 11:14am
class_name_lbl->Text = forma->ime_klase();
should probably be
class_name_lbl->Text = forma->class_name();
since you do not show what ime_klasse is.
And Form7 class_name should be declared public. But you should be doing this with a property IMO.
Nemanja Petrovic at 21-Apr-13 11:18am
no, no, i translate in eng when i copied on im my lang. i caled method : ime_kalse, but in eng it's class_name.. that's working it's not sintax eror, it smt else?
ThePhantomUpvoter at 21-Apr-13 11:26am
Perhaps you missed "And Form7 class_name should be declared public"?
Nemanja Petrovic at 21-Apr-13 11:19am
I updated q.
Nemanja Petrovic at 21-Apr-13 11:34am
Yes my man, i missed that.. Thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!! THANKS!!!!!
ThePhantomUpvoter at 21-Apr-13 19:05pm
You're welcome
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Whenever you get an error that says "inaccessible" it means that you are attempting inter-class access of either data or a method that is protected from that type of access.

The target class (the one you are trying to access) has an object marked "private" or "protected" and you are trying to over-reach this in your access attempt.

Either loosen up access to the desired item or rearchitect your code.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Posted to remove from the unanswered list.

The OP was trying to call a private function from a secondary form. Changing the accessibility to public answered his query. See the comments.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 315
1 Sergey Alexandrovich Kryukov 200
2 Richard Deeming 200
3 CPallini 160
4 CHill60 150
0 OriginalGriff 3,265
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 22 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100