0
votes

I have ComboBoxEdit filled with data and I want to put it to column.

        ComboBoxEdit cbe = new ComboBoxEdit();

        DataTable dt = Getdt();

        cbe.Properties.Items.Clear();

        foreach(DataRow item in dt.Rows)
        {
            cbe.Properties.Items.Add(item);
        }
        //ElementsEdit ee
        ee.gvView.Columns[ColumnName].ColumnEdit = cbeMaterialy;

It doesn't work. Any help appreciate ;)

PS. How can I assign full DataTable to ComboBoxEdit.

1

1 Answers

1
votes

ComboBoxEdit is a control. But, a column accepts a RepositoryItem instance as ColumnEdit. So, you need to use RepositoryItemComboBox:

    RepositoryItemComboBox cbeMaterialy = new RepositoryItemComboBox();

    DataTable dt = Getdt();

    cbeMaterialy.Items.Clear();

    foreach(DataRow item in dt.Rows)
    {
        cbeMaterialy.Items.Add(item);
    }

    gvView.Columns["ColumnName"].ColumnEdit = cbeMaterialy;

As for an editor you can use to bind it directly to a DataTable, use RepositoryItemGridLookUpEdit. It has the DataSource property to assign your DataTable.

RepositoryItemGridLookUpEdit editor = new RepositoryItemGridLookUpEdit();
editor.DataSource = dt;
column.ColumnEdit = editor;