Hi, I started recently programming in Visual C++ 2008. I have a problem with getting info from private textbox in one mdichild from another mdichild. I created public non-static function to do it however I don't know if I placed it in a proper place and how to call it from that other child.
public ref class Form2 : public System::Windows::Forms::Form
{
public:
String^ TextBoxvalue(int nr)
{
String^ controlName = "textBox" + nr.ToString();
Control^ control = this->Controls[controlName];
TextBox^ box = dynamic_cast<TextBox^>(control);
if (box != nullptr) return box->Text;
}
Form2(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form2()
{
if (components)
{
delete components;
}
}
Any advice about the code is very appreciated. A sample code how to do it would be a great help. Thanks
I came up with an idea to forward this function by a function in mdiparent however I don't know how to correctly call that function:
System::String^ Posrednik(int nr)
{
return Form2::TextBoxvalue(nr);
}
error C2352: 'Blink::Form2::TextBoxvalue' : illegal call of non-static member function
Also when I tried to call it from my other mdichild:
this->MdiParent->Posrednik(1)
I received an error:
error C2039: 'Posrednik' : is not a member of 'System::Windows::Forms::Form'
Can someone help because I don't know how to change the function from non-static to static or call it properly? Also I can't find how to add that function to 'System::Windows::Forms::Form'.