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

Focus to textbox on form after editing a cell

3 Answers 230 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 04 Nov 2010, 01:00 AM
I am editing a row in a RadGridView (WPF -- form application). I want to use the CellEditEnded event, when they are done editing a particular cell, I want to move the focus back to a textbox on the form. When the user hits Tab the CellEditEnded event fires and that seems to be the even to use.

I can trap for the column and when I call txtProductCode.Focus(); nothing happens. When I hit tab again the next cell in the same grid row has focus. So it is behaves like it needs to 'leave' the grid first.

Any thoughts?

private void gvCount_CellEditEnded(object sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e)
{
    //if edit editing on Quantity cell, then position focus to product code -- edit end typically comes from when tab key is clicked
    if (e.Cell.Column.UniqueName == "Quantity")
    {
        txtProductCode.Focus();
    }
}

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 04 Nov 2010, 11:28 AM
Hi Chad,

The CellEditEnded is fired once the editing of particular cell is over and the focus is removed to another cell. Thus navigating with the Tab key will fire this event. However, in order to meet your requirements, it may be necessary to predefine the default behavior of this particular key. On this case thought, you will change it for the whole grid. So, what is your exact requirement ? Do you want to keep the behavior of the Tab as it is by default or you want to change it ? Is the column Quantity the last one?
  

Sincerely yours,
Maya
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Chad
Top achievements
Rank 1
answered on 04 Nov 2010, 02:18 PM
Thanks for responding. Let me describe some more to help determine the best course. The grid has 8 columns, but only 3 cells that the user can enter a value. I am selecting the first cell of the 3 possible already. Then the user can hit TAB to move to the 2nd cell and enter a value then TAB again to 3rd cell and enter a value. Once they are done entering a value then hit TAB again and leave the grid to move focus to a textbox.

Sorry it is not as cut and dry as changing the entire behavior on grid.

Again the grid has 8 columns total, but the user can only edit 3 of these columns on one row at a time.

Thanks ....
0
Maya
Telerik team
answered on 05 Nov 2010, 02:59 PM
Hi Chad,

In this case you may clear the commands executed on pressing the Tab key, once the last column is reached. Afterwards, the KeyDown event will be fired and you may set the focus on the TextBox.
I am sending you a sample project illustrating the proposed solution.

Regards,
Maya
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Chad
Top achievements
Rank 1
Answers by
Maya
Telerik team
Chad
Top achievements
Rank 1
Share this question
or