Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have only a single row of a WPF DataGrid editable?

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!

like image 228
Skirde Avatar asked Sep 30 '09 05:09

Skirde


1 Answers

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;
    }
}
like image 90
Skirde Avatar answered Oct 13 '22 11:10

Skirde