Can we lock the datagrid on a row???

Dec 17, 2008 at 5:38 PM
I want to know if there's a way to be able to lock the datagrid on the current selected row.

I want to be able to move from  cell to cell within that locked row.

So when the user select a row in the datagrid and click edit, i want the row to lock. So the user will be able to move from cell to cell to edit the informations but he wont be able to select another row unless he click save (which unlock the row)

I wish there was some event like SelectionChanging that way i could do some validations and cancel the event if needed, but we only have SelectionChanged...

Any way to do this?

Dec 18, 2008 at 7:05 AM
This would be a great feature. I don't like the behavior of commiting the row when it loses focus. The default behavior must be cancel, or better there must be an option to specify behavior.
Dec 18, 2008 at 3:57 PM
I just wrote a sample for this here,  Hope that helps.
Dec 19, 2008 at 3:45 PM
Edited Dec 19, 2008 at 3:48 PM

even thought that your code is not exactly what i needed, you did point me at the right direction.

I also think that my solution support what you're trying to do. (well in my case it does)

Here's my new DataGridTools that i've created to make it work for my solution:
so if you pass to this method the datagrid you want to study and the object that you're trying to edit (in my case it's an object but it can be change to an index instead)

Thanks vinsibal for your help, greatly appreciated!










Class DataGridTools



Public Shared Sub DisableUnEditedRows(ByVal dataGrid As DataGrid, ByVal editedObject As Object)




For i As Integer = 0 To dataGrid.Items.Count - 1




Dim row = CType(dataGrid.ItemContainerGenerator.ContainerFromIndex(i), DataGridRow)




If editedObject.Equals(row.Item) Then




row.BorderBrush = Brushes.Red


row.BorderThickness =

New Thickness(2)


 row.IsSelected =



        row.IsSelected = False


row.IsEnabled = False



row.Background = Brushes.LightGray
End If





End Sub







Dec 19, 2008 at 3:49 PM
Sorry for the formating, can't seem to fix it...