我有这个问题,我管理从一种形式到另一种形式的传递int值,但我不能用字符串值(字符串也可以来自用户输入)。代码运行时,它什么都不通过。在form1代码下面:
public: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
int aaa ;
String^ dur = "Hello";
dataGridView1->Rows[0]->Cells[0]->Value = dur;
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
form2 ^ form2 = gcnew form2();
form2->aaa=10;
form2->dur;
form2->ShowDialog();
}
在Form2程序中,编号是一个数字但不是标题。代码如下:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ fileName = dur +".txt";
StreamWriter^ sw = gcnew StreamWriter(fileName);
sw->WriteLine(aaa);
sw->Close();
}