Completed
Last Updated: 05 Nov 2014 14:43 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 15 Oct 2014 06:51
Category: GridView
Type: Bug Report
0
FIX. RadGridView - Cancelling the RadDropDownListEditorElement.SelectedIndexChanging event is not actually taken into consideration
To reproduce: use the following code snippet:

public Form1()
{
    InitializeComponent();

    GridViewComboBoxColumn supplierColumn = new GridViewComboBoxColumn("SupplierID");
    supplierColumn.DataSource = this.suppliersBindingSource;
    supplierColumn.ValueMember = "SupplierID";
    supplierColumn.DisplayMember = "ContactName";
    supplierColumn.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
    this.radGridView1.Columns.Add(supplierColumn);

    this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
}

private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
    if (editor != null)
    {
        RadDropDownListEditorElement el = editor.EditorElement as RadDropDownListEditorElement;
        el.SelectedIndexChanging -= el_SelectedIndexChanging;
        el.SelectedIndexChanging += el_SelectedIndexChanging;

        el.SelectedIndexChanged -= el_SelectedIndexChanged;
        el.SelectedIndexChanged += el_SelectedIndexChanged;
    }
}

private void el_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    Console.WriteLine("Changed");
}

private void el_SelectedIndexChanging(object sender, Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs e)
{
    e.Cancel = true;
}

private void Form1_Load(object sender, EventArgs e)
{
    this.suppliersTableAdapter.Fill(this.nwindDataSet.Suppliers);
}

When the editor is initialized you will notice that the editor's value can be changed by using the mouse wheel no matter that the SelectedIndexChanging event is cancelled.
0 comments