This is a migrated thread and some comments may be shown as answers.

Press 'Enter' in FilteringControl of RadGridView

2 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 18 Jun 2012, 07:45 AM
Hi for all,

I have some problem with FilteringControl and RadGridView. I should implement this behavior: for example, when user press key 'Enter' on RadGridView's selected row I show message for him. But if user press 'Enter' in FilteringControl I should not do anything. Now it is not so (user press 'Enter' in FiletringControl's TextBox and then he will see message"Enter pressed"). I can not get access to events of FilteringControl to write "e.Handled = true;".
<telerik:RadGridView HorizontalAlignment="Left"
                     Name="radGridView"
                     AutoGenerateColumns="False"
                     PreviewKeyDown="radGridView_PreviewKeyDown"
                     VerticalAlignment="Top" Height="311" Width="503" >
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Path=Name, Mode=TwoWay}" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>
private void radGridView_PreviewKeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Enter)
    {
        MessageBox.Show("Enter pressed");
    }
}

2 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 19 Jun 2012, 09:17 AM
Hi,

You could use RadGridView.FieldFilterEditorCreated event like demonstrated in following code:

public MainWindow()
        {
            InitializeComponent();
            this.radGridView.FieldFilterEditorCreated += new EventHandler<Telerik.Windows.Controls.GridView.EditorCreatedEventArgs>(radGridView_FieldFilterEditorCreated);
        }
 
        void radGridView_FieldFilterEditorCreated(object sender, Telerik.Windows.Controls.GridView.EditorCreatedEventArgs e)
        {
            e.Editor.KeyDown += new KeyEventHandler(Editor_KeyDown);
        }
 
        void Editor_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                MessageBox.Show("Enter is pressed!");
            }
            e.Handled = true;
        }



Regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Peter
Top achievements
Rank 1
answered on 04 Jul 2012, 02:11 PM
Thanks a lot for help. Event RadGridView's FieldFilterEditorCreated is what I need.

Best regards,
Peter B.
Tags
GridView
Asked by
Peter
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Peter
Top achievements
Rank 1
Share this question
or