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

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

11 Answers 1373 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Avi
Top achievements
Rank 1
Avi asked on 06 Nov 2011, 03:44 PM
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

11 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 10 Nov 2011, 09:44 AM
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.

0
Taha
Top achievements
Rank 1
answered on 02 Feb 2012, 07:15 AM
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....
0
Peter
Telerik team
answered on 06 Feb 2012, 01:00 PM
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).

0
Taha
Top achievements
Rank 1
answered on 07 Feb 2012, 07:13 AM
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
0
Peter
Telerik team
answered on 09 Feb 2012, 12:07 PM
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 >>
0
Curtis
Top achievements
Rank 1
answered on 30 Nov 2012, 08:22 PM
When I edit a cell on the RadGridView and then tab to any other cell (not hit Enter), my application "bombs" (just shuts down).  My code only implements the CellFormatting and CellValueChanged events of the RadGridView.  If I remove (comment out) both events, I can edit a cell and tab to any other cell without the application shutting down.
0
Peter
Telerik team
answered on 05 Dec 2012, 11:17 AM
Hello Curtis,

Thank you for writing.

I have to debug your custom logic in the CellFormatting and CellValueChanged events in order to find what causes this behavior. It is possible to send us a small build-able project where the issue can be reproduced? You can do that in a new support ticket.

A bit of topic, I would kindly ask you to open a new thread for each question that is not related to the main topic of the existing threads. This will avoid mixing several different topics in one thread, hence our community will be able to find information for the topics more easily in case it is interested.

Thank you for the understanding.

Greetings,
Peter
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Curtis
Top achievements
Rank 1
answered on 05 Dec 2012, 12:54 PM
Hello, Peter

I figured out what was causing the problem.  In the CellValueChanged event, I called a method I wrote that sets the gridview's DataSource property to Nothing before reassigning it to a DataSet (in effect, clearing the gridview first).  When I deleted the code line that assigned Nothing to its DataSource property, the problem was eliminated.

Thanks for your prompt reply, Peter.

Regards,

Curtis
0
Peter
Telerik team
answered on 07 Dec 2012, 12:17 PM
Hello Curtis,

Thank you for sharing this with us - I am happy that you managed to find a solution for this case. 

Do not hesitate to contact us if you have other questions.

All the best,
Peter
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Ali
Top achievements
Rank 1
answered on 11 Dec 2017, 03:33 AM
Hi Peter,

I'm facing a similar kind of issue when I try to enter a value in the cell and either use Tab or Enter. It works fine for both, but when I come back to the same cell and wants to change first entered value. I can change that value, but can't get out from that cell either by using Enter or Tab command or by clinking with mouse to another cell.
I have to use Escape key or F2 command to get out from that cell, but I lose my change, I don't want to use this Escape or F2 option.

Is there any solution via using Tab or Enter as it works first time?

Many Thanks
Ali
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Dec 2017, 09:35 AM
Hello, Ali,

Thank you for writing.  

Following the provided information, I was unable to reproduce the issue you are facing. Please refer to the attached gif file illustrating the behavior on my end with the specified version. I have attached my sample project. Could you please specify the exact steps how to reproduce the problem? Alternatively, you can submit a support ticket where you can provide all the necessary information together with a sample project demonstrating the problem. Thus, we would be able to investigate the precise case and assist you further. Thank you. 

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Avi
Top achievements
Rank 1
Answers by
Peter
Telerik team
Taha
Top achievements
Rank 1
Curtis
Top achievements
Rank 1
Ali
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or