Home Forums WinForms controls Xceed Grid for WinForms Does anyone know the equivilent to DisplayMember?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14774 |

    In a standard combo box in winforms I set the display member to a column in my baound table. That becomes the items listed in the dropdown. value member becomes the items to return when an items is selected.

    How is this accomplished with a WinComboBox in Xceed?

    here’s my code…

    private void loadDropDownBox(WinComboBox ddl, string tableName, StringCollection settingsCollection, int selectedIndex, DataTable dt) {

    bool newTable = false;
    if (dt == null) {
    dt = new DataTable(tableName);
    dt.Columns.Add(dcItem);
    dt.Columns.Add(dcValue);
    newTable = true;
    }
    foreach (string item in settingsCollection) {
    dt.Rows.Add(item.Split(“,”.ToCharArray()));
    }
    if (newTable) {
    dsLoadData.Tables.Add(dt);
    }
    ddl.DataSource = dsLoadData.Tables[tableName];

    // DisplayMember = “item”; // <– used to be this way

    ddl.DataMember = “item”; // <– this produces an error (Impossible to bind the grid to the specified data source and member)

    ddl.ValueMember = “value”;
    ddl.SelectedIndex = selectedIndex;
    }

    Imported from legacy forums. Posted by nbkbar7 (had 2142 views)

    User (Old forums)
    Member
    Post count: 23064

    The DisplayFormat property sets what is displayed in the TextBox of the ComboBox. To set what is displayed in the Dropdown, you need to set Visible property of each column.

    e.g. :
    <i>
    winComboBox1.DataSource = dataSet11;
    winComboBox1.DataMember = “Products”;
    winComboBox1.DisplayFormat = “%ProductName%”;
    winComboBox1.ValueMember = “ProductID”;

    winComboBox1.DropDownControl.Columns[ “CategoryID” ].Visible = false;
    winComboBox1.DropDownControl.Columns[ “Discontinued” ].Visible = false;
    winComboBox1.DropDownControl.Columns[ “ProductID” ].Visible = false;
    winComboBox1.DropDownControl.Columns[ “QuantityPerUnit” ].Visible = false;
    winComboBox1.DropDownControl.Columns[ “ReorderLevel” ].Visible = false;
    winComboBox1.DropDownControl.Columns[ “SupplierID” ].Visible = false;
    winComboBox1.DropDownControl.Columns[ “UnitPrice” ].Visible = false;
    winComboBox1.DropDownControl.Columns[ “UnitsInStock” ].Visible = false;
    winComboBox1.DropDownControl.Columns[ “UnitsOnOrder” ].Visible = false;
    </i>
    This is required because the DropDownControl is in fact a grid.

    You can also use the designer to do all this.

    Imported from legacy forums. Posted by André (had 3007 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.