begin process at 2012 02 04 07:42:27
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

WPF

 > WPF MOVENEXT ET MOVEPREVIOUS

WPF MOVENEXT ET MOVEPREVIOUS


 Information sur la source

Note :
Aucune note
Catégorie :WPF Source .NET ( DotNet ) Classé sous :WPF MoveNext, DataSet MoveNext, Binding MoveNext Niveau :Débutant Date de création :01/12/2009 Date de mise à jour :02/12/2009 19:07:22 Vu :3 256

Auteur : muffin516

Ecrire un message privé
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 Description

Après avoir cherché un "movenext" en c# et WPF
j'ai bricolé un truc peut etre pas tres conventionel
c'est sans prétention mais ca  fonctionne et ca peut aider si on est pressé.
MoveFirst et MoveLast se déduisent facilement.

Source

  • la table "MaTable" contient les champs nom, prenom, appellation, metier
  • elle se trouve dans le DataSet "MonDataSet"
  • elle resulte d'une requete et comporte plusieurs lignes
  • 4 textbox dans un StackPanel sont bindées sur la table:
  • StackPanel 1.DataContext = MonDataSet.Tables["MaTable"];
  • code XAML :
  • <StackPanel1>
  • <TextBox Text="{Binding Path=nom, Mode=TwoWay}" />
  • <TextBox Text="{Binding Path=prenom, Mode=TwoWay}" />
  • <TextBox Text="{Binding Path=appellation, Mode=TwoWay}" />
  • <TextBox Text="{Binding Path=metier, Mode=TwoWay}" />
  • <StackPanel1 />
  • CODE C# :
  • // variable de classe
  • int NumeroDeRow = 0;
  • //....
  • private void button1_Click(object sender, RoutedEventArgs e) // MoveNext
  • {
  • if NumeroDeRow < MonDataSet.Tables["MaTable"].Rows.Count -1 )
  • {
  • NumeroDeRow ++;
  • var contacts = (MonDataSet.Tables["MaTable"] as IListSource).GetList();
  • DataRowView drv = (DataRowView)contacts[NumeroDeRow];
  • StackPanel1.DataContext = drv;
  • }
  • }
  • private void button2_Click(object sender, RoutedEventArgs e) // MovePrevious
  • {
  • if NumeroDeRow > 0 )
  • {
  • NumeroDeRow --;
  • var contacts = (MonDataSet.Tables["MaTable"] as IListSource).GetList();
  • DataRowView drv = (DataRowView)contacts[NumeroDeRow];
  • StackPanel1.DataContext = drv;
  • }
  • }
la table "MaTable" contient les champs nom, prenom, appellation, metier
elle se trouve dans le DataSet "MonDataSet"
elle resulte d'une requete et comporte plusieurs lignes 

4 textbox dans un StackPanel sont bindées sur la table:
StackPanel 1.DataContext = MonDataSet.Tables["MaTable"];

code XAML :

<StackPanel1>
<TextBox  Text="{Binding Path=nom, Mode=TwoWay}"  />
<TextBox Text="{Binding Path=prenom, Mode=TwoWay}"  />
<TextBox  Text="{Binding Path=appellation, Mode=TwoWay}"  />
<TextBox Text="{Binding Path=metier, Mode=TwoWay}"  />
<StackPanel1 />

CODE C# :


// variable de classe

int  NumeroDeRow = 0;
//....
 private void button1_Click(object sender, RoutedEventArgs e)  // MoveNext
        {
          
            if NumeroDeRow < MonDataSet.Tables["MaTable"].Rows.Count -1 )
            {
                NumeroDeRow ++;
              
                var contacts = (MonDataSet.Tables["MaTable"] as IListSource).GetList();

                DataRowView drv = (DataRowView)contacts[NumeroDeRow];

                StackPanel1.DataContext = drv;
            }
           }

 private void button2_Click(object sender, RoutedEventArgs e) // MovePrevious 
        {
          
            if NumeroDeRow > 0 )
            {
                NumeroDeRow --;
              
                var contacts = (MonDataSet.Tables["MaTable"] as IListSource).GetList();

                DataRowView drv = (DataRowView)contacts[NumeroDeRow];

                StackPanel1.DataContext = drv;
            }
           }



 Historique

02 décembre 2009 19:07:22 :
petite erreur dans le code DataRowView drv = (DataRowView)contacts[IdentCRow]; IdentCRow n'existe pas c'est bien sûr NumeroDeRow : DataRowView drv = (DataRowView)contacts[NumeroDeRow];

 Sources du même auteur

Source .NET (Dotnet) LIRE DATETIME AVEC MILLISECONDES DANS SQL SERVER

 Sources de la même categorie

Source avec Zip OUTIL DE VISUALISATION DE L'INDICE BOURSIER par ajkangoud
Source avec Zip Source avec une capture Source .NET (Dotnet) [WPF] RICH TEXT FORMAT par MasterShadows
Source avec Zip Source .NET (Dotnet) [WPF] GÉNÉRATEUR DE DOCUMENT XPS MULTIPAGES. par MasterShadows
Source avec Zip Source avec une capture Source .NET (Dotnet) WPF MESSAGE BOX ET WPF FOLDER SELECTOR par MasterShadows
Source avec Zip Source avec une capture Source .NET (Dotnet) EXPLORATEUR DE REGISTRE WINDOWS par thebestdrummer

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,562 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales