radvirualgrid

2 Answers 145 Views
VirtualGrid
atfat
Top achievements
Rank 1
Iron
Iron
atfat asked on 23 Jun 2021, 02:55 AM

hi,

i want to use the radvirtualgrid to add a new row/record to a database but instead of using Tab button to switch between column i prefer to use the enter key.

is that possible, if yes can you give me a sample please ?

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 23 Jun 2021, 04:32 PM

Hello, Atfat,

If I understand you correctly, you want to move the selection to the next cell when pressing the Enter key instead of the Tab key. To achieve this behavior you can handle the PreviewKeyDown event as follows:

this.radVirtualGrid1.PreviewKeyDown += RadVirtualGrid1_PreviewKeyDown;
private void RadVirtualGrid1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        this.radVirtualGrid1.VirtualGridElement.MoveCurrentRight(true);
    }
}

I hope this helps. If you have other questions do not hesitate to ask.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

atfat
Top achievements
Rank 1
Iron
Iron
commented on 26 Jun 2021, 04:23 AM

Hello Nadya
it does not work
please can you send me a sample to illustrate how to use radvirtualgrid to add a new row with an enter key to move to next column in vb.net
thank you
0
Nadya | Tech Support Engineer
Telerik team
answered on 28 Jun 2021, 03:12 PM

Hello, Atfat,

Please refer to the following sample in VB which result is illustrated in the provided gif file:

   Public Sub New()
        InitializeComponent()
        Me.radVirtualGrid1.RowCount = 30
        Me.radVirtualGrid1.ColumnCount = 6
        AddHandler Me.radVirtualGrid1.CellValueNeeded, AddressOf radVirtualGrid1_CellValueNeeded
       AddHandler Me.radVirtualGrid1.PreviewKeyDown, AddressOf RadVirtualGrid1_PreviewKeyDown
    End Sub

    Private Sub RadVirtualGrid1_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs)
        If e.KeyCode = Keys.Enter Then
            Me.radVirtualGrid1.VirtualGridElement.MoveCurrentRight(True)
        End If
    End Sub

    Private Sub radVirtualGrid1_CellValueNeeded(ByVal sender As Object, ByVal e As VirtualGridCellValueNeededEventArgs)
        If e.RowIndex = -1 Then
            e.Value = "Col" & e.ColumnIndex
        Else
            e.Value = "Name" & e.RowIndex + e.ColumnIndex
            e.FieldName = "Col" & e.ColumnIndex
        End If
    End Sub

Is this the result that you want to obtain when pressing the Enter key in the virtual grid? If you have more custom requirements, it would be greatly appreciated if you can provide more information about the desired behavior.

I hope this helps. Please let me know if I can assist you further.

Regards,
Nadya
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
VirtualGrid
Asked by
atfat
Top achievements
Rank 1
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or