Dissecting Data To Control Binding


We're going to discuss on what to do with DataBinding, DataSet, DataTable and other relevant classes.

Code Inspection

Let's start by investigating these codes:

private BindingSource bindingSource = new BindingSource;
    private TextBox textBoxFirst = new TextBox();
    private TextBox textBoxSecond = new TextBox();
    // Initialise binding source
    public void Init()
        DataSet ds = new DataSet();
        // set binding source to dataset
        bindingSource = ds;
        // set data member to NewColumn table
        bindingSource.DataMember = "NewTable";
        // perform data binding to existing controls
        textBoxFirst.DataBindings.Add("Text", bindingSource, "NewColumn", true, DataSourceUpdateMode.OnPropertyChanged);
        textBoxSecond.DataBindings.Add("Text", bindingSource, "NewColumn", true, DataSourceUpdateMode.OnPropertyChanged);
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License