Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > GridView > Enter key for moving to next cell on a new row when the cell is set to ReadOnly

Answered Enter key for moving to next cell on a new row when the cell is set to ReadOnly

Feed from this thread
  • Avi avatar

    Posted on Nov 6, 2011 (permalink)

    Hi,

    I use RadControls for WinForms Q2 2011.

    I've set a column on my grid to ReadOnly for both EnterKeyMode and NewRowEnterKeyMode.

    When navigating through cells with either Tab or Enter keys - it works fine and it jumps to the next editable cell. But, When navigating with Enter key on a new row through the read-only column - it stays on that cell and doesn't move on. I need to use Esc, arrows or mouse to release it.

    Is it the right behavior? If so, is there some workaround for that?

    Best Regards,

    Boaz

    Reply

  • Answer Peter Peter admin's avatar

    Posted on Nov 10, 2011 (permalink)

    Hi Avi,

    Thank you for writing and sorry for the late response.

    When you press the Enter key in EnterMovesToNextCell we always move to the next cell and we consider this behavior as normal. In case that the cell is read-only you cannot edit it and should press enter again.
    You can easy workaround this behavior. You  should CurrentColumnChanged event and skip the column if the column is ReadOnly:

    this.radGridView1.CurrentColumnChanged += new Telerik.WinControls.UI.CurrentColumnChangedEventHandler(radGridView1_CurrentColumnChanged);          
            }
             
            void radGridView1_CurrentColumnChanged(object sender, Telerik.WinControls.UI.CurrentColumnChangedEventArgs e)
            {
                if (e.NewColumn.ReadOnly)
                {
                    int nextIndex = e.NewColumn.Index + 1;
                    if (nextIndex >= this.radGridView1.Columns.Count)
                    {
                        nextIndex = 0;
                    }
     
                    this.radGridView1.CurrentColumn = this.radGridView1.Columns[nextIndex];
                }
            }

    Please, refer to the attached project.
    I hope this helps.

    Kind regards,
    Peter
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

    Attached files

    Reply

  • Taha avatar

    Posted on Feb 2, 2012 (permalink)

    Hi
    1 ) I want to change position tab between cells by enter key but I can't
    2)  if tab was last cell, by enter key create new row and tab go to first cell in new row

    tnx alot....

    Reply

  • Peter Peter admin's avatar

    Posted on Feb 6, 2012 (permalink)

    Hello Taha,

    Thank you for writing.

    1) In order to change the current cell with Enter key instead of the Tab key, you should set RadGridView's EnterKeyMode property to EnterMovesToNextCell:

    radGridView1.EnterKeyMode = RadGridViewEnterKeyMode.EnterMovesToNextCell;

    2) You should set RadGridView's NewRowEnterKeyMode property to EnterMovesToNextCell
    radGridView1.NewRowEnterKeyMode = RadGridViewNewRowEnterKeyMode.EnterMovesToNextCell;

    I hope this helps. Do not hesitate to contact us if you have other questions.

    Regards,
    Peter
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

    Reply

  • Taha avatar

    Posted on Feb 7, 2012 (permalink)

    Hi
    i 'm taha
    About Question 2 , So i could't create new row by enter key when tab
    is last cell in last row
    please help me.
    tnx

    Reply

  • Peter Peter admin's avatar

    Posted on Feb 9, 2012 (permalink)

    Hi,

    You should set RadGridView's AllowAddNewRow property to true.
    When set to true an empty row is added in which the user can enter data for the new record.

    radGridView1.AllowAddNewRow = true;

    I hope this helps. Kind regards,
    Peter
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > GridView > Enter key for moving to next cell on a new row when the cell is set to ReadOnly
Related resources for "Enter key for moving to next cell on a new row when the cell is set to ReadOnly"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]