Suppression dernière ligne datagrid [Résolu]

Signaler
-
Messages postés
125
Date d'inscription
jeudi 26 mai 2005
Statut
Membre
Dernière intervention
22 septembre 2019
-
Bonjour,
Je suis debutant et jaimerai savoir comment supprimer la dernière ligne vide qui s'affiche dans mon datagrid. Jai aussi joint une image pour illustrer mon problème.
Merci d'avance.
Voici mon code xaml


<DataGrid Name="Liste_civio" HorizontalAlignment="Left" Margin="20,219,0,0" VerticalAlignment="Top" Width="740" Height="Auto" AutoGenerateColumns="False" CanUserResizeRows="False" >

<DataGrid.AlternatingRowBackground>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
<GradientStop Color="#FFF6F6F6"/>
</LinearGradientBrush>
</DataGrid.AlternatingRowBackground>

<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=DossierCivioID}" Header="N° Civio" Width="98" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=CodeTypeDossier}" Header="Type" Width="40" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=CodeStation}" Header="Station" Width="90" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=a1}" Header="Importateur " Width="185" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=ReferenceCilog}" Header="N° Cilog " Width="70" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=OperateurDateOperationCaisse, StringFormat={}{0:MM/dd/yy}}" Header="Date Enreg " Width="142" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=libstatu}" Header="Statut " Width="*" IsReadOnly="True" />
</DataGrid.Columns>
</DataGrid>



Ensuite mon code behing :
  private void FillDataGrid()
{


string ConString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
string CmdString = string.Empty;
using (SqlConnection con = new SqlConnection(ConString))
{
//MessageBox.Show("connexion ok", "My Application");
CmdString = @"SELECT TOP 10 t1.DossierCivioID, t1.CodeTypeDossier,
t1.CodeStation, t2.NomImportateur as a1 , t1.ReferenceCilog, t1.OperateurDateOperationCaisse ,
t3.LibelleStatut as libstatu
FROM CivioReceptionDossier as t1, Importateur as t2,CivioReceptionDossierStatut as t3
where t2.ImportateurID=t1.ImportateurID
and t1.CodeStatut=t3.CodeStatut
and t1.CodeStatut>'04'
and t1.OperateurDateOperationCaisse>'20150101' ";
SqlCommand cmd = new SqlCommand(CmdString, con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable("t1, t2");
sda.Fill(dt);
Liste_civio.ItemsSource = dt.DefaultView;
}

1 réponse

Messages postés
125
Date d'inscription
jeudi 26 mai 2005
Statut
Membre
Dernière intervention
22 septembre 2019

Merci j'ai trouver la solution il fallait mettre mon la propriété de mon datagrid : IsReadOnly="True" soit
 <DataGrid  Name="Liste_civio" IsReadOnly="True" HorizontalAlignment="Left" Margin="20,219,0,0" VerticalAlignment="Top" Width="740" Height="Auto"  AutoGenerateColumns="False" CanUserResizeRows="False"  >


--