Reputation: 151
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!
Upvotes: 6
Views: 3855
Reputation: 151
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;
}
}
Upvotes: 9
Reputation: 91625
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.
Upvotes: 0