Click here to Skip to main content
15,896,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

C#
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

C#
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:
"
VB
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
Updated 21-Apr-13 5:18am
v2
Comments
[no name] 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.
[no name] 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?
[no name] 21-Apr-13 11:26am    
Perhaps you missed "And Form7 class_name should be declared public"?
[no name] 21-Apr-13 11:19am    
I updated q.
[no name] 21-Apr-13 11:34am    
Yes my man, i missed that.. Thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!! THANKS!!!!!

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.
 
Share this answer
 
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900