-2

也许标题不正确,但我不知道如何提问。我有一个带有多个使用单例的选项卡的 Windows 窗体。好吧,我的表单大约有 50 多个文本框,它们将用户输入存储到我的单例属性中,然后保存到 xml。我的问题是读取 xml 并在文本框上显示保存到 xml 的内容的不太复杂的路径是什么?示例代码:

public class ContactInfo
   {
    public string Name { get { return Firstname + " " + LastName; } }

    public string Firstname { get; set; }

    public string LastName { get; set; }

    public string PhoneNumber { get; set; }

    public string Email { get; set; }

    public string Address1 { get; set; }

    public string Address2 { get; set; }

    public string City { get; set; }

    public string State { get; set; }

    public string ZipCode { get; set; }
   }
public class Site
{
Site()
 {
        OfficeAddress = new ContactInfo();
        ShippingAddress = new ContactInfo();
        DirectorOfOperationsFandB = new ContactInfo();
        DirectorOfOperationsRetail = new ContactInfo();
        SecondInCharge = new ContactInfo();
        SiteController = new ContactInfo();
        SiteContact = new ContactInfo();
  }
    public ContactInfo OfficeAddress { get; set; }

    public ContactInfo ShippingAddress { get; set; }

    public ContactInfo DirectorOfOperationsFandB { get; set; }

    public ContactInfo DirectorOfOperationsRetail { get; set; }

    public ContactInfo SecondInCharge { get; set; }
  }

我开始做 textbox1.text = Site.OfficeAdress.Address1; 等等,但你无法想象会占用多少行。

4

1 回答 1

0

您可以像这样以两种方式绑定文本框:

textBox1.DataBindings.Add(new Binding("Text", ds, "customers.custName"));

有关更多详细信息 http://msdn.microsoft.com/en-us/library/system.windows.forms.control.databindings.aspx

于 2013-05-01T22:26:43.723 回答