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 datasource combobox


Sujet :

C#

  1. #1
    Membre averti
    Inscrit en
    Mai 2009
    Messages
    21
    Détails du profil
    Informations forums :
    Inscription : Mai 2009
    Messages : 21
    Par défaut Problème datasource combobox
    Bonjour,
    J'ai créer un user control dans lequel il y a une combobox, je souhaite remplir la combobox grâce à ma base de données donc j'utilise datasource dans les propriété de la combobox je choisi mon Display Member et mon value member, lorsque je fais le preview j'ai bien mes champs mais lorsque je lance mon appli il n'y a rien dans ma combo.
    J'ai essayé de créer une combo dans ma form principale en utilisant le même datasource que précédemment et là ma combo est rempli pk ?
    Merci

  2. #2
    Membre Expert Avatar de Guulh
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    2 160
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2007
    Messages : 2 160
    Par défaut
    Salut,

    où et comment affectes tu une datasource à ton user control ?

  3. #3
    Membre averti
    Inscrit en
    Mai 2009
    Messages
    21
    Détails du profil
    Informations forums :
    Inscription : Mai 2009
    Messages : 21
    Par défaut
    j'affecte la datasource à ma combobox qui se situe dans mon usercontrol

  4. #4
    Membre Expert Avatar de Guulh
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    2 160
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2007
    Messages : 2 160
    Par défaut
    Faudrait détailler un peu, hein

    Où affectes tu la datasource ? Dans le code du constructeur ? Via le designer ? Ailleurs ?

    Tu peux montrer le code ?

  5. #5
    Membre averti
    Inscrit en
    Mai 2009
    Messages
    21
    Détails du profil
    Informations forums :
    Inscription : Mai 2009
    Messages : 21
    Par défaut
    Le code est généré directement via le wizard datasource dans les propriété de la combobox

    Est ce que ce code peut aidé?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    private void InitializeComponent()
            {
                this.components = new System.ComponentModel.Container();
                this.comboBox1 = new System.Windows.Forms.ComboBox();
                this.licenceDataSet = new test_datasource.licenceDataSet();
                this.companyBindingSource = new System.Windows.Forms.BindingSource(this.components);
                this.companyTableAdapter = new test_datasource.licenceDataSetTableAdapters.companyTableAdapter();
                this.licenceDataSet1 = new test_datasource.licenceDataSet1();
                this.companyBindingSource1 = new System.Windows.Forms.BindingSource(this.components);
                this.companyTableAdapter1 = new test_datasource.licenceDataSet1TableAdapters.companyTableAdapter();
                ((System.ComponentModel.ISupportInitialize)(this.licenceDataSet)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.companyBindingSource)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.licenceDataSet1)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.companyBindingSource1)).BeginInit();
                this.SuspendLayout();
                // 
                // comboBox1
                // 
                this.comboBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.companyBindingSource, "nom", true));
                this.comboBox1.DataSource = this.companyBindingSource1;
                this.comboBox1.DisplayMember = "nom";
                this.comboBox1.FormattingEnabled = true;
                this.comboBox1.Location = new System.Drawing.Point(28, 24);
                this.comboBox1.Name = "comboBox1";
                this.comboBox1.Size = new System.Drawing.Size(121, 21);
                this.comboBox1.TabIndex = 0;
                this.comboBox1.ValueMember = "cid";
                // 
                // licenceDataSet
                // 
                this.licenceDataSet.DataSetName = "licenceDataSet";
                this.licenceDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
                // 
                // companyBindingSource
                // 
                this.companyBindingSource.DataMember = "company";
                this.companyBindingSource.DataSource = this.licenceDataSet;
                // 
                // companyTableAdapter
                // 
                this.companyTableAdapter.ClearBeforeFill = true;
                // 
                // licenceDataSet1
                // 
                this.licenceDataSet1.DataSetName = "licenceDataSet1";
                this.licenceDataSet1.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
                // 
                // companyBindingSource1
                // 
                this.companyBindingSource1.DataMember = "company";
                this.companyBindingSource1.DataSource = this.licenceDataSet1;
                // 
                // companyTableAdapter1
                // 
                this.companyTableAdapter1.ClearBeforeFill = true;
                // 
                // combo
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.Controls.Add(this.comboBox1);
                this.DataBindings.Add(new System.Windows.Forms.Binding("Tag", this.companyBindingSource, "nom", true, System.Windows.Forms.DataSourceUpdateMode.Never));
                this.Name = "combo";
                ((System.ComponentModel.ISupportInitialize)(this.licenceDataSet)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.companyBindingSource)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.licenceDataSet1)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.companyBindingSource1)).EndInit();
                this.ResumeLayout(false);

Discussions similaires

  1. Réponses: 3
    Dernier message: 09/09/2008, 01h20
  2. probléme de combobox
    Par benazerty dans le forum Access
    Réponses: 1
    Dernier message: 11/04/2006, 17h33
  3. [DEBUTANT - VBA] Problèmes de ComboBox
    Par _Maniak dans le forum Général VBA
    Réponses: 13
    Dernier message: 10/03/2006, 10h02
  4. Problème de ComboBox...
    Par lerouzes dans le forum Composants VCL
    Réponses: 3
    Dernier message: 18/01/2006, 18h14
  5. Problème affichage ComboBox et barre déroulante!
    Par ghan77 dans le forum Composants VCL
    Réponses: 4
    Dernier message: 17/01/2006, 14h09

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