Data binding for TextBox

后端 未结 4 1808
难免孤独
难免孤独 2020-11-28 09:04

I have a basic property that stores an object of type Fruit:

Fruit food;
public Fruit Food
{
    get {return this.food;}
    set
    {
        this.food= val         


        
4条回答
  •  悲哀的现实
    2020-11-28 09:16

    We can use following code

    textBox1.DataBindings.Add("Text", model, "Name", false, DataSourceUpdateMode.OnPropertyChanged);
    

    Where

    • "Text" – the property of textbox
    • model – the model object enter code here
    • "Name" – the value of model which to bind the textbox.

提交回复
热议问题