Completed
Last Updated: 27 Dec 2016 16:18 by ADMIN
ADMIN
Dimitar
Created on: 23 Dec 2016 09:26
Category: VirtualGrid
Type: Bug Report
1
FIX. RadVirtualGrid - exception when the editor is VirtualGridDropDownListEditor and key is pressed
To reproduce:
- Change the editor to VirtualGridDropDownListEditor
- Press alpha-numeric key when the grid is not in edit mode.

Workaround:
 radVirtualGrid1.VirtualGridElement.InputBehavior = new MyBehavior(radVirtualGrid1.VirtualGridElement);

class MyBehavior : VirtualGridInputBehavior
{
    public MyBehavior(RadVirtualGridElement element) : base(element)
    {

    }
    protected override bool HandleAlphaNumericKey(KeyPressEventArgs keys)
    {
        if (!this.GridElement.IsInEditMode &&
            (this.GridElement.BeginEditMode == RadVirtualGridBeginEditMode.BeginEditOnKeystroke ||
             this.GridElement.BeginEditMode == RadVirtualGridBeginEditMode.BeginEditOnKeystrokeOrF2))
        {
            //this.GridElement.HideContextMenu();
            this.GridElement.BeginEdit();
            if (this.GridElement.ActiveEditor is VirtualGridDropDownListEditor)
            {
                string symbol = keys.KeyChar.ToString();
                var editor = this.GridElement.ActiveEditor as VirtualGridDropDownListEditor;
                var element = editor.EditorElement as RadDropDownListEditorElement;

                if ((element.AutoCompleteMode & AutoCompleteMode.Append) == AutoCompleteMode.Append)
                {
                    int index = element.AutoCompleteAppend.FindShortestString(symbol);

                    if (index == -1)
                    {
                        element.EditableElementText = symbol;
                        element.EditableElement.SelectionStart = 1;
                        element.EditableElement.SelectionLength = 0;

                        return true;
                    }
                }
               
            }
            return false;
        }

        return base.HandleAlphaNumericKey(keys);
    }
}
0 comments