Simple Bind

Make the simple GUI below and add Binding Provider component tot the Form

Create User Class

    public class User
    {
        public Guid Id { get; set; } = Guid.NewGuid();
        public string Name { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }
        public string Address { get; set; }
        public string Notes { get; set; }
 }

Bind Sample Data

 public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            User user = new User()
            {
                Name = "John Doe",
                Email ="doe@email.com",
                Address = "Belvue WA 00100" ,
                Notes="Hello World",
                Phone="+1-800-000-0000"
            };

            bindingProvider1.Bind(user);
        }
    }

Match The Binding Properties

Select a textbox, Go to properties and find the ktBinding Property

Enter the Data property and enter the user property name to bind with.

Leave the Property to Text.

Do the same for the rest of the controls you wish to bind.

Leave the Data property blank to skip binding

run the program.

Congratulations!!!.. You just binded your fist Object.

Last updated