簡體   English   中英

表單將數據發送到另一表單

[英]Form sending data to another form

我目前正在嘗試制作一個發送2類的表單,然后接收數據,使用它們,但想要將其拍攝回原始表單。 關於我該怎么辦?

這是當我打電話給我的第二種形式:

        var tmp = new Pjeu(P1,P2);
        tmp.Show();

P是玩家。 這是課程:// ---

public class Player
{
    public string Name;
    public int pts1;
    public int pts2;
    public int num;
};

我收到這樣的數據:

label3.Text = P1.Name;
label5.Text=P2.Name;

我想使用P1.ptsP1.pts發射一個數字。 我可以這樣做嗎?

您可以使用多種方式:

public class Player
{
    public void Pa(string p1,string p2)
    {
        p1 = Name;
        p2 = Name;
    }
    public string pass1(int ps1)
    {
        return ps1.ToString();
    }
    public string pass2(int ps2)
    {
        return ps2.ToString();
    }
    public string Name { get; set; }
    public int pts1 { get; set; }
    public int pts2 { get; set; }
    public int num { get; set; }
}

並致電:

        Player p = new Player();
        p.Pa(Label1.Text, Label2.Text);
        Label1.Text = p.pts1.ToString();
        Label2.Text = p.pts2.ToString();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM