Click here to Skip to main content
Rate this: bad
good
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) {
                
                class_name();
             }
 

Here is code for FORM1
 
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
            
             Form7^ forma = gcnew Form7();
             forma->ShowDialog();
             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..?
TNX!
Posted 21-Apr-13 5:46am
Edited 21-Apr-13 6:18am
v2
Comments
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 codeproject.com 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
good
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.
  Permalink  
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 22 Apr 2013
Copyright © CodeProject, 1999-2014
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