How to move gridview selected row up/down on KeyUp or Keydown press

2 posts, 1 answers
  1. ajoua taha
    ajoua taha avatar
    25 posts
    Member since:
    Feb 2016

    Posted 07 Mar Link to this post

    So as the title states, I'm trying to navigate between rows in a GridView when a cell* ( * : cell correspond to third row and quantity column in my case )  is editing by clicking up/down , so when i navigate up/down , the new selected row also have cell* editing   , here is my gridview

    <telerik:RadGridView Grid.Row="2" Grid.ColumnSpan="3"
             x:Name="gridview"
             ItemsSource="{Binding CurrentDetailBLLs}"
             SelectedItem="{Binding SelectedCurrentDetailBLL,Mode=TwoWay}"                  
             SelectionMode="Extended"
             CanUserDeleteRows="True"
             CanUserInsertRows="True"
             IsReadOnly="False"
             IsFilteringAllowed="False"
             AutoGenerateColumns="False"
             GroupRenderMode="Flat"
             AutoExpandGroups="True"
             NewRowPosition="None"
             IsSynchronizedWithCurrentItem="True" KeyUp="dataGridView1_KeyUp">
                <!--SelectionUnit="FullRow"-->
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn
                                TextAlignment="Justify"
                                Width="auto"
                                HeaderTextAlignment="Center"
                                DataMemberBinding="{Binding Path=ProductID}"
                                Header="ProductCode" />
                    <telerik:GridViewDataColumn
                                TextAlignment="Justify"
                                Width="auto"
                                HeaderTextAlignment="Center"
                                DataMemberBinding="{Binding Path=ProductName}"
                                Header="ProductName" IsReadOnly="True">
                    </telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn
                                TextAlignment="Center"
                                        Width="auto"
                                HeaderTextAlignment="Center"
                                DataMemberBinding="{Binding Path=Quantity}"
                                Header="Quantity"/>
     
                </telerik:RadGridView.Columns>

    the attached image make clear what i am talking about .

    help plz !

  2. Answer
    Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    280 posts

    Posted 08 Mar Link to this post

    Hi Taha,

    Thank you for the image and the code provided.

    As the default TextBox handles the KeyDown and KeyUp events, it is not possible to use a Custom Keyboard Command Provider, which usually is the way to go in such scenarios. What you need to do is handle the PreviewKeyDown event of the RadGridView and perform the logic for pressing the Up and Down keys inside.

    I have created a sample project that implements the desired behavior. Please, review it and update me if such approach would be useful. 

    I will be looking forward to your reply.

    Regards,
    Stefan Nenchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top