Lecture de la ligne courante d'un DatagridView
Bonjour à tous,
En C# ( WPF4), j'utilise un datagridview avec un binding sur un objet.
Je voudrais pouvoir faire un contrôle lors de la saisie de ma ligne.
J'ai donc ajouté l'évenenement : dataGrid1_RowEditEnding
Voici ma procédure :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
private void dataGrid1_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
TableCompte Compte = e.Row.DataContext as TableCompte;
if (Compte != null)
{
// Verifs
}
} |
Mon problème est que l'objet compte est toujours nul !
Voici mon code XAML
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
<DataGrid AutoGenerateColumns="false" Name="dataGrid1" AreRowDetailsFrozen="false" Margin="31,227,28,82" RowEditEnding="dataGrid1_RowEditEnding">
<DataGrid.Columns>
<DataGridTextColumn Width="134" Header="Compte d'origine" Binding="{Binding Path=m_CompteOrigine, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<DataGridTextColumn Width="134" Header="Compte Taux 1" Binding="{Binding Path=m_CompteTaux1, Mode=TwoWay ,UpdateSourceTrigger=PropertyChanged}" />
<DataGridTextColumn Width="134" Header="Taux 1" Binding="{Binding Path=m_Taux1, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged }" />
<DataGridTextColumn Width="134" Header="Compte Taux 2" Binding="{Binding Path=m_CompteTaux2, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
<DataGridTextColumn Width="134" Header="Taux 2" Binding="{Binding Path=m_Taux2, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged }" />
<DataGridTextColumn Width="134" Header="Compte Taux 3" Binding="{Binding Path=m_CompteTaux3, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
<DataGridTextColumn Width="134" Header="Taux 3" Binding="{Binding Path=m_Taux3, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged }" />
</DataGrid.Columns>
</DataGrid> |
Voyez vous d'ou pourrait venir mon erreur ?
Je vous remercie à tous,
Bien cordialement,
Nixeus