多个文本框2方式绑定
本文关键字:绑定 2方 文本 | 更新日期: 2023-09-27 18:11:48
也许标题不正确,但我不知道如何提问。我有一个Windows窗体的多个选项卡,使用单例。我的表单大约有50多个文本框,这些文本框将用户输入存储到我的singleton属性中,然后保存为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 . officeaddress . address1;等等但是你无法想象这要占用多少行
你可以这样绑定textBox:
textBox1.DataBindings.Add(new Binding("Text", ds, "customers.custName"));
查看详细信息http://msdn.microsoft.com/en-us/library/system.windows.forms.control.databindings.aspx