0

了解しました。これが私の問題です。私はほぼすべてを完了しました。フォームから入力を取得し、それを2番目のフォームのアルゴリズムで使用する必要があります。私は他のすべてを書き留めています。最後のコードを書き上げることができるように、2を接続する方法を知る必要があります。私はいくつかの調査を行いましたが、それは私がやろうとしていることとうまくいかないようです。

これがメインフォームです。

namespace Airplanes
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void Arrival_Click(object sender, EventArgs e)
        {
            ArrivalForm newForm;
            newForm = new ArrivalForm();
            newForm.ShowDialog();

        }

        private void Fuel_Click(object sender, EventArgs e)
        {
            Fuelform newForm2;
            newForm2 = new Fuelform();
            newForm2.ShowDialog();

        }

        private void Status_Click(object sender, EventArgs e)
        {


        }

        private void Items_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void NameBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void FuelBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void GateBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void Singlebutton_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void PrivateButton_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void CommercialButton_CheckedChanged(object sender, EventArgs e)
        {

        }

    }
}

そして、これが私がメインフォームに接続しようとしているフォームです。

namespace Airplanes
{
    public partial class Fuelform : Form
    {
        public Fuelform()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void Fuelform_Load(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }
}

回答をよろしくお願いします。

4

2 に答える 2

4

いくつかの方法があります...おそらく最も簡単なのは、新しいフォームのコンストラクターを介してデータを渡すことです。

FuelForm newForm2 = new FuelForm(myData);

次に、FuelFormのコンストラクターを変更します。

public FuelForm(int myData)  // or whatever data type you need
{
    // Deal with myData
}
于 2012-11-28T03:23:11.340 に答える
1

ソース形式

 destinationForm df = new destinationForm ();
            df .myValue= "My Value";
            df .ShowDialog();

宛先フォーム

  private string destVariable;

     public string myValue
            {
                get { return destVariable; }
                set { destVariable= value; }
            }

次に、宛先形式でどこでもdestVariableを使用できます

于 2012-11-28T03:27:44.263 に答える