Completed
Last Updated: 19 Aug 2013 06:32 by ADMIN
ADMIN
Georgi I. Georgiev
Created on: 19 Aug 2013 06:32
Category: MultiColumnCombo
Type: Bug Report
0
FIX. RadMultiColumnComboBox - ArgumentOutOfRangeException when bound to DataTable
To reproduce:
void Form1_Load(object sender, EventArgs e)
{
    this.radMultiColumnComboBox2.AutoSizeDropDownToBestFit = true;

    RadMultiColumnComboBoxElement multiColumnComboElement2 = this.radMultiColumnComboBox2.MultiColumnComboBoxElement;

    multiColumnComboElement2.EditorControl.MasterTemplate.AutoGenerateColumns = true;

    DataTable dt = GetDataTable();
    this.radMultiColumnComboBox2.DataSource = dt;

    FilterDescriptor descriptor3 = new FilterDescriptor("Station", FilterOperator.Contains, null);
    this.radMultiColumnComboBox2.EditorControl.FilterDescriptors.Add(descriptor3);

    FilterDescriptor descriptor4 = new FilterDescriptor("StationName", FilterOperator.Contains, null);
    this.radMultiColumnComboBox2.EditorControl.FilterDescriptors.Add(descriptor4);

    this.radMultiColumnComboBox2.EditorControl.FilterDescriptors.LogicalOperator = FilterLogicalOperator.Or;

    radMultiColumnComboBox2.AutoFilter = true;
}

private DataTable GetDataTable()
{
    DataTable dt = new DataTable();

    dt.Columns.Add("Station"); //, typeof(Int32));
    dt.Columns.Add("StationName");

    System.Data.DataRow row1 = dt.NewRow();
    System.Data.DataRow row2 = dt.NewRow();
    System.Data.DataRow row3 = dt.NewRow();
    System.Data.DataRow row4 = dt.NewRow();
    System.Data.DataRow row5 = dt.NewRow();
    System.Data.DataRow row6 = dt.NewRow();
    System.Data.DataRow row7 = dt.NewRow();
    System.Data.DataRow row8 = dt.NewRow();
    System.Data.DataRow row9 = dt.NewRow();
    System.Data.DataRow row10 = dt.NewRow();

    row1["Station"] = "285";
    row1["StationName"] = "Bob";

    row2["Station"] = "274";
    row2["StationName"] = "Mary";

    row3["Station"] = "222";
    row3["StationName"] = "Joan";

    row4["Station"] = "289";
    row4["StationName"] = "William";

    row5["Station"] = "385";
    row5["StationName"] = "Bob";

    row6["Station"] = "374";
    row6["StationName"] = "Mary";

    row7["Station"] = "331";
    row7["StationName"] = "Jane";

    row8["Station"] = "389";
    row8["StationName"] = "William";

    row9["Station"] = "281";
    row9["StationName"] = "Bob";

    row10["Station"] = "273";
    row10["StationName"] = "Mary";

    dt.Rows.Add(row1);
    dt.Rows.Add(row2);
    dt.Rows.Add(row3);
    dt.Rows.Add(row4);
    dt.Rows.Add(row5);
    dt.Rows.Add(row6);
    dt.Rows.Add(row7);
    dt.Rows.Add(row8);
    dt.Rows.Add(row9);
    dt.Rows.Add(row10);

    return dt;
}

Start the application and type 2738 (273 is the last row), then press the up arrow twice, exception should occur.

Workaround:
public class MyRadMultiColumnComboBox : RadMultiColumnComboBox
{
    protected override RadMultiColumnComboBoxElement CreateMultiColumnComboBoxElement()
    {
        return new MyRadMultiColumnComboBoxElement();
    }
}

public class MyRadMultiColumnComboBoxElement : RadMultiColumnComboBoxElement
{
    protected override void ProcessKeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Up)
        {
            GridViewRowInfo row = this.GetCurrentRow(true);
            if (row != null)
            {
                int index = row.Index;
                if (index == -1)
                {
                    if (this.Rows.Count > 0)
                    {
                        this.EditorControl.CurrentRow = this.Rows[0];
                    }

                    return;
                }
            }
        }

        base.ProcessKeyDown(sender, e);
    }

    protected override Type ThemeEffectiveType
    {
        get
        {
           return typeof(RadMultiColumnComboBoxElement);
        }
    }
}
0 comments