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

Composants VCL Delphi Discussion :

Incrémenter l'item d'un ComboBox


Sujet :

Composants VCL Delphi

  1. #1
    Inactif
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut Incrémenter l'item d'un ComboBox
    Bonjour,
    Je voudrais savoir comment on peut incrémenter l'item d'un ComboBox de +1.
    Merci d'avance.

  2. #2
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    Salut et bienvenue sur developpez.com pour incrementer l'item d'une comboBox utilise ComboBox1.Itemsindex:=ComboBox1.Itemsindex+1

  3. #3
    Inactif
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Merci pour la bienvenue et le code

  4. #4
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    De rien bonne prog et pense au tag en bas a gauche

  5. #5
    Inactif
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Parcontre comment on peut savoir le numéro du dernier item ?
    Merci d'avance.

  6. #6
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    Tout simplement avec
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ComboBox1.items.count;
    Bonne Prog !!

  7. #7
    Inactif
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Enfaite je voudrais que quant je suis sur le dernier item du ComboBox2 sa m'incrémente l'item du ComboBox1 de +1 et que sa me remette le ComboBox2 à l'item 0, alors j'ai essayé mais sa ne marche pas :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    if ComboBox2.ItemIndex = ComboBox1.Items.Count
    then
    begin
    ComboBox2.ItemIndex := 0;
    ComboBox1.ItemIndex := +1;
    end;
    ComboBox2.ItemIndex := ComboBox2.ItemIndex+1;
    Merci d'avance.

  8. #8
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    Quelle est ton message d'erreur as tu bien placer ton code dans le OnChange du ComboBox2

    De plus tu compar sur ta premiere ligne le ComboBox2 avec le ComboBox1 je pense que tu as fait une erreur c'est ComboBox2.Items.count

  9. #9
    Inactif
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Je n'es pas de message d'erreur, voici le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    procedure TForm1.Button7Click(Sender: TObject);
    begin
    if ComboBox2.ItemIndex = ComboBox2.Items.Count
    then
    begin
    ComboBox2.ItemIndex := 0;
    ComboBox1.ItemIndex := ComboBox1.ItemIndex+1;
    end;
    ComboBox2.ItemIndex := ComboBox2.ItemIndex+1;
    end;

  10. #10
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    Ton itemsindex commence a - 1 tu dois donc utiliser
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if ComboBox2.ItemIndex = ComboBox2.Items.Count-1
    then
    begin
    ComboBox2.ItemIndex := -1;
    ComboBox1.ItemIndex := ComboBox1.ItemIndex+1;
    end;
    ComboBox2.ItemIndex := ComboBox2.ItemIndex+1;
    end;

  11. #11
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    Dis moi si c'est bon !!

  12. #12
    Inactif
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Sa marche merci !
    Parcontre j'ai un ComboBox3, je veut qu'il s'incrémente de +1 quant le ComboBox1 et à son dernier item et que sa remmete le ComboBox1 & ComboBox2 à zéro et doncc j'ai essayer mais sa ne marche pas :
    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
     
    procedure TForm1.Button7Click(Sender: TObject);
    begin
    if ComboBox2.ItemIndex = ComboBox2.Items.Count-1
    then
    begin
    ComboBox2.ItemIndex := -1;
    ComboBox1.ItemIndex := ComboBox1.ItemIndex+1;
    end;
    if ComboBox1.ItemIndex = ComboBox1.Items.Count-1
    then
    begin
    ComboBox1.ItemIndex := -1;
    ComboBox3.ItemIndex := ComboBox3.ItemIndex+1;
    end;
    ComboBox

  13. #13
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    Tu devrais trouver ta betise tout seul normalement tu as oublier de mettre une ligne

    Allez c'est noel je te donne ton code :

    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
     
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if ComboBox2.ItemIndex = ComboBox2.Items.Count-1
      then begin
      ComboBox2.ItemIndex := -1;
      ComboBox1.ItemIndex := ComboBox1.ItemIndex+1;
      end;
    ComboBox2.ItemIndex := ComboBox2.ItemIndex+1;
    if ComboBox1.ItemIndex = ComboBox1.Items.Count-1
      then begin
      ComboBox1.ItemIndex := -1;
      ComboBox3.ItemIndex := ComboBox3.ItemIndex+1;
      end;
    end;

  14. #14
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    Tu avais oublier d'incrementer ta combobox2 :
    ComboBox2.ItemIndex := ComboBox2.ItemIndex+1;
    pense a :Resolu: sa devrait allez normalement a moin que tu es un soucis avec combobox4

  15. #15
    Inactif
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Lol non pas de ComboBox4 mdrr
    Non sinon ya tout qui marche sauf que dans la ComboBox1 om y as 3 items et le troisieme s'affiche tjr en blanc.

  16. #16
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    Comment sa en blanc ne s'affiche pas tu veux dire car la couleur de fond de la combobox est blanche

  17. #17
    Inactif
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Bas j'ai trois prénoms :
    - benjamin
    - nat
    - pat

    Pour benjamin et nat sa marche mais pas pour pat.

  18. #18
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    c'est normal car tu lui demande que quand ComboBox est sur le dernier item de l'effacé essaye ca :
    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
     
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if ComboBox2.ItemIndex = ComboBox2.Items.Count-1
      then begin
      ComboBox2.ItemIndex := -1;
      ComboBox1.ItemIndex := ComboBox1.ItemIndex+1;
      end;
    ComboBox2.ItemIndex := ComboBox2.ItemIndex+1;
    if (ComboBox1.ItemIndex = ComboBox1.Items.Count-1) and (ComboBox2.ItemIndex=ComboBox2.Items.Count-1)
      then begin
      ComboBox1.ItemIndex := -1;
      ComboBox3.ItemIndex := ComboBox3.ItemIndex+1;
      end;
    end;

  19. #19
    Inactif
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 11
    Points : 2
    Points
    2
    Par défaut
    Merci sa marche parfaitement, parcontre dernière question jurer lol, tu sais comment on incrémente un label ?

  20. #20
    Membre averti
    Avatar de jmjmjm
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2005
    Messages
    760
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2005
    Messages : 760
    Points : 439
    Points
    439
    Par défaut
    que veux tu faire exactement je ne vois pas trop?

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. [VB .NET] Copier les Items d'un ComboBox Vers un Autre
    Par D4rkTiger dans le forum Windows Forms
    Réponses: 6
    Dernier message: 06/08/2006, 12h05
  2. [C#] Changement d'item dans la comboBox
    Par cyllix dans le forum Windows Forms
    Réponses: 1
    Dernier message: 20/06/2006, 09h12
  3. Recherche d'un item dans un combobox
    Par Remedy dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 03/06/2006, 10h35
  4. [VB.NET2005]PropertyGrid : utiliser un item d'une combobox
    Par NicolasJolet dans le forum Windows Forms
    Réponses: 1
    Dernier message: 30/03/2006, 15h51
  5. [VB.Net][DataGrid] Comment retirer des items d'un ComboBox ?
    Par graphicsxp dans le forum Windows Forms
    Réponses: 9
    Dernier message: 20/12/2005, 11h46

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