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

GridView cell selection

2 Answers 219 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 17 Dec 2010, 06:34 PM

Hello guys

I'm evaluating RadControls for WPF and OA ORM for my next project. I'm just playing with it for just one day, but I'm already impressed with your work guys. Though, as a beginner, I can't figure out how to select a cell when new row is added to gridview. In other words, I want to select first editable cell and put it in edit mode when new row is added from InsertRow button. How is this accomplished?

EDITED
_____________________________

I will ask this one too here.
When cell validation fails, it would be nice to show the error message, without the need to move the cursor to the cell's red point. Is it also possible? 

EDITED 2 :)
____________________________

is it possible to tell gridview not to change selection until all cells of the grid is validated? now it's possible to persist rows despite validation failure, which breaks business rule.

thanks 

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 21 Dec 2010, 10:20 AM
Hello David,

In case you want the first cell of a new item to be focused, you need to handle the AddingNewDataItem of the grid like follows:

private void playersGrid_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
        {
            this.playersGrid.CurrentColumn = this.playersGrid.Columns.OfType<GridViewColumn>().First();
            //this.playersGrid.CurrentColumn = this.playersGrid.Columns[3] as GridViewDataColumn;
            e.NewObject = new Player();
        }

The fist line of code sets the first column as the current one, while the second one - the fourth column. You may use either method. The current column is that one that gets the focus.
You second requirement is also achievable with predefining some of the grid's templates. You may take a look at this forum thread for a reference and a sample project. 
As for your last requirement, I would need a bit more details about the exact scenario you want to accomplish. What do you mean by not changing the selection until the cells are validated ? 

 

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
David
Top achievements
Rank 1
answered on 21 Dec 2010, 04:25 PM
Thank you for your response maya. I already found the solution for third problem, but your reply really helped for other questions. Thanks again.
Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Maya
Telerik team
David
Top achievements
Rank 1
Share this question
or