IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

problème avec dataGridView vers textbox et combobox


Sujet :

C#

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 11
    Par défaut problème avec dataGridView vers textbox et combobox
    Bonsoir tout le monde,

    Voila, j'ai fais un formulaire dans lequel j'ai un dataBridView, je remonte dans le dataBridView des données de la base, ensuite je veux "dispacher" une ligne du dataBridView vers des textbox ou combobox:

    Voici mon code:


    DataTable laRechercheAdherent = connection.recherche_adherent(valSearchNom.Text.ToUpper(), lePrenom);

    listeAdherent.DataSource = laRechercheAdherent;

    for (int i = 0; i < listeAdherent.Rows.Count; i++)
    {
    valNom.Text = listeAdherent.Rows[i][0].ToString();
    valPrenom.Text = listeAdherent.Rows[i][1].ToString();
    valNaiss.Text = listeAdherent.Rows[i][3].ToString();
    valAdresse.Text = listeAdherent.Rows[i][4].ToString();
    valVille.Text = listeAdherent.Rows[i][5].ToString();
    valCP.Text = listeAdherent.Rows[i][6].ToString();
    valTelPort.Text = listeAdherent.Rows[i][7].ToString();
    valLicence.Text = listeAdherent.Rows[i][10].ToString();
    valPhoto.Text = listeAdherent.Rows[i][11].ToString();

    string laCivilité = laRechercheAdherent.Rows[i][2].ToString();

    if (laCivilité == "F")
    valFeminin.Checked = true;

    else
    valMasculin.Checked = true;


    string leNiveau = laRechercheAdherent.Rows[i][9].ToString();

    // rechercher le niveau
    string leLibNiveau = connection.recup_libNiveau(leNiveau);
    MessageBox.Show(leLibNiveau);
    valAncienNiveau.Text = leLibNiveau;

    string leForfait = connection.recup_libForfait(laRechercheAdherent.Rows[i][8].ToString());
    valAncienForfait.Text = leForfait;
    }
    }
    catch
    {
    MessageBox.Show("Echec de transfert", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
    }

    Le compilateur me met:

    Erreur 1 Impossible d'appliquer l'indexation à l'aide de [] à une expression de type



    Merci pour votre aide.

  2. #2
    Membre émérite Avatar de ppphil
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    617
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Juin 2007
    Messages : 617
    Par défaut
    Pis comme ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    valNom.Text = listeAdherent.Rows[i].Cells[0].ToString();

  3. #3
    Membre Expert Avatar de sisqo60
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Février 2006
    Messages
    754
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 754
    Par défaut
    ppphil a raison mais si tu veux utiliser [][], il faut utiliser la propriété cells

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    for (int i = 0; i < listeAdherent.Rows.Count; i++)
    {
    valNom.Text = listeAdherent.Cells[i][0].ToString();
    valPrenom.Text = listeAdherent.Cells[i][1].ToString();
    valNaiss.Text = listeAdherent.Cells[i][3].ToString();
    valAdresse.Text = listeAdherent.Cells[i][4].ToString();
    valVille.Text = listeAdherent.Cells[i][5].ToString();
    valCP.Text = listeAdherent.Cells[i][6].ToString();
    valTelPort.Text = listeAdherent.Cells[i][7].ToString();
    valLicence.Text = listeAdherent.Cells[i][10].ToString();
    valPhoto.Text = listeAdherent.Cells[i][11].ToString();
    }

Discussions similaires

  1. Problème avec Modified de TextBox
    Par bubulemaster dans le forum Windows Forms
    Réponses: 5
    Dernier message: 10/04/2008, 10h23
  2. Problème avec DataGridView
    Par andy38 dans le forum VB.NET
    Réponses: 10
    Dernier message: 24/01/2008, 02h14
  3. Problème avec DataGridView et Localizable
    Par blistex dans le forum ASP.NET
    Réponses: 3
    Dernier message: 10/07/2007, 16h28
  4. Problème avec StingTokenizer vers tableau de String
    Par Invité dans le forum Collection et Stream
    Réponses: 9
    Dernier message: 06/10/2006, 11h22

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo