Vite fait et pas forcément très optimisé
la classe:
public class ExempleLevotre123
{
public int Numero1 { get; set; }
public int Numero2 { get; set; }
public int Numero3 { get; set; }
public int Numero4 { get; set; }
public string NomDuGars { get; set; }
public string TypeCompte { get; set; }
/// <summary>
/// Retourne le texte formaté comme il faut
/// </summary>
/// <returns></returns>
public string Affcihe()
{
return string.Format("{0}|{1}|{2}|{3}|{4}|{5}", Numero1.ToString("00"), Numero2, Numero3, Numero4.ToString("00000"), NomDuGars, TypeCompte);
}
/// <summary>
/// incrémente le numéro3
/// </summary>
public void Suivant()
{
Numero3++;
}
}
et la méthode qui crée 5 enregistrements
private void testLevotre123()
{
ExempleLevotre123 toto = new ExempleLevotre123();
toto.Numero1 = 5;
toto.Numero2 = 5;
toto.Numero3 = 405246;
toto.Numero4 = 100;
toto.NomDuGars = "Monsieur Untel";
toto.TypeCompte = "Compte comme ça";
for (int i = 0; i < 5; i++)
{
listBox1.Items.Add(toto.Affcihe());//listBox1 est une liste box sur le formulaire
toto.Suivant();
}
}