views:

511

answers:

2

I have a data set that I want to display to the user, but I only want them to be able to edit the newest (first) row of data. I need to display the other rows of data to them for reference. I don’t have to keep everything in the same DataGrid but would like to if possible.

I’m new to WPF so any help/ideas are greatly appreciated!

A: 

Regardless of what UI toolkit you use, datagrids usually only allow one field of one row to be edited at a time. The user can only focus on a single field at any point to fill it in. At which point they must click or tab to the next field to continue to add content.

Of course, there's the less common multi-select edit that you can do in a spreadsheet, but most datagrids don't work that way out of the box, or need certain settings changed in order to allow it.

Soviut
Right. The key I'm looking for is to make sure that the user can only ever edit the first row of the grid so rows 2 - n behave as read only.
Skirde
A: 

Got it, I'm just canceling out of the edit of any row other than the first one.

private void dataGridStats_BeginningEdit(object sender, DataGridBeginningEditEventArgs e) { if (e.Row.GetIndex() != 0) e.Cancel = true; }

Skirde
You may want to have a dedicated form that sits above and below the grid and use that for editing rather than forcing inline editing of a single row. It sort of defeats the purpose of the grid.
Soviut