Unplanned
Last Updated: 30 Mar 2016 08:13 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 28 Mar 2016 08:19
Category: GridView
Type: Bug Report
0
FIX. RadGridView - missing first keystroke in RadMultiColumnComboBoxElement
To reproduce:

1. Add a RadGridView with a GridViewMultiComboBoxColumn. Enable the auto filter functionality for this column and add an appropriate FilterDescriptor to the RadMultiColumnComboBoxElement.
2. Using the keyboard arrows only (no mouse), navigate to the GridViewMultiComboBoxColumn.
3. Type "ba" by using the keyboard. The "b" is lost and only the "a" gets to the filter. I expect the filter to show "ba".

Workaround: use custom row behavior

public Form1()
{
    InitializeComponent();
    //register the custom row  behavior
    BaseGridBehavior gridBehavior = radGridView1.GridBehavior as BaseGridBehavior;
    gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo));
    gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior());
}

public class CustomGridDataRowBehavior : GridDataRowBehavior
{
    protected override bool ProcessAlphaNumericKey(KeyPressEventArgs keys)
    {
        bool result = base.ProcessAlphaNumericKey(keys);
        if (this.IsInEditMode &&
            (this.BeginEditMode == RadGridViewBeginEditMode.BeginEditOnKeystroke ||
             this.BeginEditMode == RadGridViewBeginEditMode.BeginEditOnKeystrokeOrF2))
        {
            if (this.GridViewElement.ActiveEditor is RadMultiColumnComboBoxElement)
            {
                this.GridViewElement.ActiveEditor.Value = keys.KeyChar;
                if (this.GridViewElement.IsInEditMode)
                {
                    RadMultiColumnComboBoxElement mccb = (RadMultiColumnComboBoxElement)this.GridViewElement.ActiveEditor;
                    RadTextBoxItem textBoxItem = mccb.TextBoxElement.TextBoxItem;
                    textBoxItem.Clear();
                    textBoxItem.Text =  keys.KeyChar.ToString();
                    textBoxItem.SelectionStart = 1;
                    textBoxItem.SelectionLength = 0;
                }

                return true;
            }
        }
        return result;
    }
}
0 comments