Calendar for WinForms | ComponentOne
DateEdit / Data-Binding
In This Topic
    Data-Binding
    In This Topic

    Binding a control with a data source gives you the ability to communicate and even update the underlying data through the control. Data binding in DateEdit helps to establish a connection between the user interface of the control and the data it displays.

    DateEdit control showing a particular date for OrderDate, an example for databinding.

    The DateEdit control can be bound to a data source using the DataSource property of the C1DropDownEditorBase class. You can specify the field to be bound to the control using the DataMember property.

    C#
    Copy Code
    // Create a datasource
    dt = new DataTable();
    string command = "SELECT * from invoices";
    OleDbDataAdapter da = new OleDbDataAdapter(command,GetConnectionString());
    da.Fill(dt);
    bSource = new BindingSource();
    bSource.DataSource = dt;
    // Bind the DateEdit control to datasource
    dateEdit.DataSource = bSource;
    dateEdit.DataMember = "OrderDate";