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

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

1 Answer 446 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ajoua taha
Top achievements
Rank 1
ajoua taha asked on 07 Mar 2016, 11:22 AM

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 !

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan Nenchev
Telerik team
answered on 08 Mar 2016, 11:23 AM
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
Tags
GridView
Asked by
ajoua taha
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or