Completed
Last Updated: 28 Sep 2016 06:40 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 21 Jul 2016 10:02
Category: GridView
Type: Bug Report
0
FIX. RadGridView - cancelling the CellValidating event when pressing Enter key while a GridColorPickerEditor is active triggers the CellValidating event a second time
To reproduce:

public Form1()
{
    InitializeComponent();
    List<Item> items = new List<Item>();
    for (int i = 0; i < 10; i++)
    {
        items.Add(new Item(i,"Item" + i,Color.Red));
    }
    this.radGridView1.DataSource = items;
    this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
    this.radGridView1.CellValidating += radGridView1_CellValidating;
}

private void radGridView1_CellValidating(object sender, Telerik.WinControls.UI.CellValidatingEventArgs e)
{
    if (e.ActiveEditor != null && e.ActiveEditor is GridColorPickerEditor)
    {
        Color c = (Color)e.Value;
        if (c == Color.Red)
        {
            e.Cancel = true;
            Console.WriteLine("Red is not allowed!");
        }
    }
}

public class Item
{
    public int Id { get; set; }

    public string Name { get; set; }

    public Color Color { get; set; }

    public Item(int id, string name, Color color)
    {
        this.Id = id;
        this.Name = name;
        this.Color = color;
    }
}

Steps:
1. Activate the editor for the Color cell.
2. Leave the color as it
3. Press the Enter key. The CellValidating event is fired twice.

Note: it seems that when the color text is selected, the event is fired twice.

(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments