如何从另一种形式的一个表单中查看文本框条目

时间:2014-08-27 15:01:08

标签: windows c++-cli

我正在尝试将textBox1值从Form5传递给Form1。但是,当它到达Form1时似乎没有记住或看到它的值。我希望paf_path成为paf_path2

System::Void Form5::button1_Click(System::Object^  sender, System::EventArgs^  e) {

    System::String^ paf_path2 = textBox1->Text;

    FolderBrowserDialog^ folderBrowserDialog1;
    folderBrowserDialog1 = gcnew System::Windows::Forms::FolderBrowserDialog;
    folderBrowserDialog1->Description = L"Select the directory of your MAF files ";
    folderBrowserDialog1->ShowNewFolderButton = false;

    // Show the FolderBrowserDialog.
    System::Windows::Forms::DialogResult result = folderBrowserDialog1->ShowDialog();
    if (result == ::DialogResult::OK)
    {
        paf_path2 = folderBrowserDialog1->SelectedPath;
    }

    textBox1->Text = paf_path2;
}

System::Void Form5::button2_Click(System::Object^  sender, System::EventArgs^  e){
    Form1 ^dos3 = gcnew Form1(this);
    dos3->Show();
    this->Hide();
}

System::Void Form1::button1_Click(System::Object^  sender, System::EventArgs^  e) {
    System::String^ test = textBox1->Text;

    if (test == "")
    {
        MessageBox::Show("Please enter partial address!");
    }
    else
    {
        Form5^doss = gcnew Form5(this);
        System::String^ paf_path2 = doss->textBox1->Text;
        char* paf_path = (char*) (void*) Marshal::StringToHGlobalAnsi(paf_path2);

0 个答案:

没有答案