掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
別のフォームにデータを渡すには? (ID:69692)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
--- Form2側 public ref class Form2 : public System::Windows::Forms::Form { ... private: String^ userInput_; // 変数追加 // "ボタン押された"ハンドラ System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { userInput_ = textBox1->Text; DialogResult = System::Windows::Forms::DialogResult::OK; Close(); } public: // メソッド追加 String^ GetUserInput() { return userInput_; } }; --- Form1側 public ref class Form2 : public System::Windows::Forms::Form { ... private: // "ボタン押された"ハンドラ System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { // Form2を生成し Form2^ form = gcnew Form2(); // モーダル表示。OKだったら if ( form->ShowDialog() == System::Windows::Forms::DialogResult::OK ) { // ユーザ入力を取得してtextboxへ。 textBox1->Text = form->GetUserInput(); } } };
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.