我可以将对象映射或自动映射到表单,然后从表单映射到对象吗?我有以下代码:
// Class model
class Model1
{
Property1;
Property2;
Property3;
...
}
// Form. I use this form to create and update data of Model1
public partial class FormModel1 : Form
{
private Model1 model1;
...
private void LoadData()
{
Property1Txt.Text = model1.Property1;
Property2Txt.Text = model1.Property2;
Property3Txt.Text = model1.Property3;
}
private void SaveButton_Click(object sender, EventArgs e)
{
model1.Property1 = Property1Txt.Text;
model1.Property2 = Property2Txt.Text;
model1.Property3 = Property3Txt.Text;
model1.Save();
}
}
请注意,我已经简化了示例。我想将数据从我的模型设置到表单,从表单设置到我的模型。
我怎样才能做到这一点?