HeaderPane
Main
Hide
Share Link
Print

DataSource Property, SftBox Class

Defines the data source whose rows become the items of the list.

Class: SftBox
Namespace: Softelvdm.SftBoxNET
Assembly: Softelvdm.SftBoxNET

Syntax

public object DataSource { get; set; }
Public Property DataSource As Object

Value

A list (IList, such as an array or a List), a list source (IListSource, such as a DataTable or DataSet), a BindingSource, or null/Nothing to show the items added by the application.

The default value is null/Nothing.

Comments

Defines the data source whose rows become the items of the list.

This is the list's ListClass.DataSource property: each row becomes an item, the columns' ColumnClass.DataMember properties name the values shown in their cells, and the list follows the changes of the data source. When no column names a member, the first column shows the SftBox.DisplayMember value of each row.

The SftBox.SelectedValue property returns the SftBox.ValueMember value of the selected item's row; binding it to a property of another object (DataBindings) makes the combo box a lookup field for that property.

Examples

C# View entire sample code

            countries.Rows.Add(34, "Spain", "Madrid");

            sftBox6.Columns.Count = 2;
            sftBox6.Columns[0].DataMember = "Name";
            sftBox6.Columns[1].DataMember = "Capital";
            sftBox6.DropDownWidthMode = DropDownWidthModeEnum.Optimal;
            sftBox6.DisplayMember = "Name";
            sftBox6.ValueMember = "Id";
            sftBox6.DataSource = countries;

            order.CountryId = 81;
            order.PropertyChanged += delegate { ShowOrder(); };
            sftBox6.DataBindings.Add("SelectedValue", order, "CountryId", false, DataSourceUpdateMode.OnPropertyChanged);
            ShowOrder();
        }

VB.NET View entire sample code

        countries.Rows.Add(34, "Spain", "Madrid")

        SftBox6.Columns.Count = 2
        SftBox6.Columns(0).DataMember = "Name"
        SftBox6.Columns(1).DataMember = "Capital"
        SftBox6.DropDownWidthMode = DropDownWidthModeEnum.Optimal
        SftBox6.DisplayMember = "Name"
        SftBox6.ValueMember = "Id"
        SftBox6.DataSource = countries

        order.CountryId = 81
        AddHandler order.PropertyChanged, Sub() ShowOrder()
        SftBox6.DataBindings.Add("SelectedValue", order, "CountryId", False, DataSourceUpdateMode.OnPropertyChanged)
        ShowOrder()
    End Sub

See Also SftBox Class | Classes | SftBox/NET 3.0