begin process at 2010 07 30 13:07:22
  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 :1 879

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 SILVERLIGHT 4: BOUTON À 3 IMAGES par BumpMANN
Source avec Zip Source avec une capture Source .NET (Dotnet) [WPF] GESTION ET CREATION BDD ACCESS POUR LES SINOGRAMMES + ... par jerem3000
Source avec Zip Source avec une capture TIC TAC TOE par monssif007
Source avec Zip Source avec une capture Source .NET (Dotnet) [WPF] RÉSOLVEUR DU JEU RICOCHET ROBOT par MasterShadows
Source avec Zip Source avec une capture Source .NET (Dotnet) TOP MEMBRES CS par buno

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Juillet 2010
LMMJVSD
   1234
567891011
12131415161718
19202122232425
262728293031 

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,718 sec (4)

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