如何将类对象子表单发送到父表单c#

时间:2016-03-05 08:36:15

标签: c#

我想将子窗体中的类对象发送到父窗体。请帮我举例。谢谢!

ChildForm:

QSharedPointer<int> myQSharedPointer

1 个答案:

答案 0 :(得分:0)

试试这个......

ChildForm:

public class OtherCompanyBinaryFormatSerializer
{
    public void Serialize<T>(Stream stream, T object); { ... }
    public T Deserialize<T>(Stream stream); { ... }
}

ParentForm:

public partial class Form2 : Form
{
    // private List of Person(s)
    private List<Person> PersonsList = new List<Person>();

    // Public Read-only property that you can call from you Parent Form
    public List<Person> Frm2PersonsList
    {
        get
        {
            return this.PersonsList;
        }
    }

    public Form2()
    {
        InitializeComponent();
    }

    private void btnGonder_Click(object sender, EventArgs e)
    {
        SendItems();
        this.Close();
    }

    public void SendItems()
    {
        Person pr = new Person();
        pr.telebe = "Set in form 2"; // set you Person properties here
        PersonsList.Add(pr);
    }
}