Bonjour , comment je suprime une ligne de StringGrid si elle verifie pas la condition.merci d'avance pour votre aide.
Bonjour , comment je suprime une ligne de StringGrid si elle verifie pas la condition.merci d'avance pour votre aide.
Bonjour,
tout d'abord, si elle vérifie pas la condition ? Quel condition ??
Si tu n'est pas plus précis, on ne pourra pas beaucoup t'aider.
Deuxièmement il y as le code qui permet de supprimer une ligne d'un StringGrid dans la FAQ : ici
A plus
pottiez
salut tout le monde
finalement j'ai vu que c'est pas important de supprimé la ligne et de affiché une forme au lieu de la supprission en fait j'ai utilsé ce code
je veut pour la 1er if si la condition n'est pas verifié, la form6 s'affiche
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 int e;int f; String chaine1,chaine; String M1,M2;int pos3; int pos4; int a,b; {for(int i=1;i<Form4->StringGrid5->RowCount;i++) { if(Form4->StringGrid5->Cells[1][i]==Form2->ComboBox5->Text) { AnsiString chaine = Form4->StringGrid5->Cells[0][i]; {if(int pos1 = chaine.Pos(Form2->ComboBox4->Text)) {chaine1= Form2->ComboBox2->Text; e=StrToInt(chaine1); chaine= Form4->StringGrid5->Cells[2][i]; M1=chaine.SubString(chaine.Pos("[")+1,(chaine.Pos(",")-chaine.Pos("["))-1); a=StrToInt(M1); M2= chaine.SubString(chaine.Pos(",")+1,(chaine.Pos("]")-chaine.Pos(","))-1); b=StrToInt(M2); {if(e >= a&& e<= b) {Form7->Visible=true;} else {Form3->Visible=true;} }}}}}}
et la meme chose pour 2eme if .j'espere que ma question est claire.merci d'avance pour votre aide.
Je ne comprend ou est ton problème ?? si tu veux simplement afficher une form en fonction de ta condition il suffit de mettre dans ton if :je veut pour la 1er if si la condition n'est pas verifié, la form6 s'affiche
et la meme chose pour 2eme if .j'espere que ma question est claire.merci d'avance pour votre aide.
pense à mettre "Unit6.h" dans l'en-tête de ton cpp....
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 if(Form4->StringGrid5->Cells[1][i]==Form2->ComboBox5->Text) { AnsiString chaine = Form4->StringGrid5->Cells[0][i]; TForm6 * form6; form6= new TForm6(Form6); form6->Visible= true;
J'espère que tu pourras avancer
Aide les autres...
Et les autres t'aideront....
Mon site DVP
N'oubliez pas de consulter les FAQ SharePoint et les cours et tutoriels SharePoint
N'oubliez pas de voter pour les messages dont la réponse est pertinente
Bonjour, en fait mon code est valide que si la conditionest verifié , je veut pour le cas contraire , si aucune ligne de cette colonne n'egale
Code : Sélectionner tout - Visualiser dans une fenêtre à part if(Form4->StringGrid5->Cells[1][i]==Form2->ComboBox5->Text)
la form 6 s'affiche .merci d'avance pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part Form2->ComboBox5->Text
Salut,
Déjà, une remarque, écrit ton code, clairement si tu veut t'y retrouver, en voyant ton code je n'ai pas envie de m'y plonger dedans pour te dire l'endroit ou mettre le code, alors que je sais quel code mettre pour résoudre ton problème.
Donc ton code écrit clairement donne :
Déjà on remarque tout de suite que tu as des accolade en trop (mise en rouge ici) ce n'est pas une erreur, mais ça ne sert pas ici.
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 int e; int f; String chaine1,chaine; String M1,M2; int pos3; int pos4; int a,b; { for(int i=1;i<Form4->StringGrid5->RowCount;i++) { if(Form4->StringGrid5->Cells[1][i]==Form2->ComboBox5->Text) { AnsiString chaine = Form4->StringGrid5->Cells[0][i]; { if(int pos1 = chaine.Pos(Form2->ComboBox4->Text)) { chaine1= Form2->ComboBox2->Text; e=StrToInt(chaine1); chaine= Form4->StringGrid5->Cells[2][i]; M1=chaine.SubString(chaine.Pos("[")+1,(chaine.Pos(",")-chaine.Pos("["))-1); a=StrToInt(M1); M2= chaine.SubString(chaine.Pos(",")+1,(chaine.Pos("]")-chaine.Pos(","))-1); b=StrToInt(M2); { if(e >= a&& e<= b) { Form7->Visible=true; } else { Form3->Visible=true; } } } } } } }
Ensuite maintenant je pense que si tu ne sais pas faire les conditions if (puisqu'il s'agit de ta question à la base) tu devrait consulter quelque tuto sur le c ou le c++
Je te donne tout de même la réponse, il faut mettre un else pour mettre le code lorsque ta condition ne se verifie 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
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 int e; int f; String chaine1,chaine; String M1,M2; int pos3; int pos4; int a,b; for(int i=1;i<Form4->StringGrid5->RowCount;i++) { if(Form4->StringGrid5->Cells[1][i]==Form2->ComboBox5->Text) { AnsiString chaine = Form4->StringGrid5->Cells[0][i]; if(int pos1 = chaine.Pos(Form2->ComboBox4->Text)) { chaine1= Form2->ComboBox2->Text; e=StrToInt(chaine1); chaine= Form4->StringGrid5->Cells[2][i]; M1=chaine.SubString(chaine.Pos("[")+1,(chaine.Pos(",")-chaine.Pos("["))-1); a=StrToInt(M1); M2= chaine.SubString(chaine.Pos(",")+1,(chaine.Pos("]")-chaine.Pos(","))-1); b=StrToInt(M2); if(e >= a&& e<= b) { Form7->Visible=true; } else { Form3->Visible=true; } } } else { //Affichage de la form6 Form6->Show(); } }
salut ,merci pottier , mais je veut la fiche 6 s'affiche que si tout les lignes de la colonne de StringGrid5 n'égale pas.parce que ton code il regarde si la premiere ligne egale pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part comboBox5->Textla forme 6 s'affiche et la valeur existe dans la suite de StringGrid.merci d'avance pour votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part comboBox5->Text
Salut,
dans ce cas, il faut tester avec un booléen, ici afficherForm, par défaut il affichera la form (true), mais si la condition est vrai au moins une foit il ne l'affichera pas (false)
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 int e; int f; String chaine1,chaine; String M1,M2; int pos3; int pos4; int a,b; bool afficherForm = true; for(int i=1;i<Form4->StringGrid5->RowCount;i++) { if(Form4->StringGrid5->Cells[1][i]==Form2->ComboBox5->Text) { AnsiString chaine = Form4->StringGrid5->Cells[0][i]; afficherForm = false; if(int pos1 = chaine.Pos(Form2->ComboBox4->Text)) { chaine1= Form2->ComboBox2->Text; e=StrToInt(chaine1); chaine= Form4->StringGrid5->Cells[2][i]; M1=chaine.SubString(chaine.Pos("[")+1,(chaine.Pos(",")-chaine.Pos("["))-1); a=StrToInt(M1); M2= chaine.SubString(chaine.Pos(",")+1,(chaine.Pos("]")-chaine.Pos(","))-1); b=StrToInt(M2); if(e >= a&& e<= b) { Form7->Visible=true; } else { Form3->Visible=true; } } } } if(afficherForm) Form6->Show();
merci beaucoup ça marche bien , j'ai fait la meme chose pour la 2eme condition if .mé je me suis trouvé dans un cas qui s'affiche la form 6 et 8 et je veut quand s'affiche la forme 6 la fiche 8 ne s'affiche pas .j'ai met
Code : Sélectionner tout - Visualiser dans une fenêtre à part if(Form6->Visible ==true) Form8->Close();
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 mé ça ce voi dans l'inteface quel est parti.merci d'avance pour votre aide. int e; int f; String chaine1,chaine; String M1,M2; int pos3; int pos4; int a,b; bool afficherForm = true; bool afficherForm1 = true; for(int i=1;i<Form4->StringGrid5->RowCount;i++) { if(Form4->StringGrid5->Cells[1][i]==Form2->ComboBox5->Text) { AnsiString chaine = Form4->StringGrid5->Cells[0][i]; afficherForm = false; if(int pos1 = chaine.Pos(Form2->ComboBox4->Text)) {afficherForm1 = false; chaine1= Form2->ComboBox2->Text; e=StrToInt(chaine1); chaine= Form4->StringGrid5->Cells[2][i]; M1=chaine.SubString(chaine.Pos("[")+1,(chaine.Pos(",")-chaine.Pos("["))-1); a=StrToInt(M1); M2= chaine.SubString(chaine.Pos(",")+1,(chaine.Pos("]")-chaine.Pos(","))-1); b=StrToInt(M2); if(e >= a&& e<= b) { Form7->Visible=true; } else { Form3->Visible=true; } } } } if(afficherForm) Form6->Show(); if(afficherForm1) Form8->Show()
Salut,
ajoute simplement le else comme j'ai mis en rouge, comme sa il va testé pour affiché la form6, et si il n'affiche pas la 6, il test si il doit afficher la 8
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 mé ça ce voi dans l'inteface quel est parti.merci d'avance pour votre aide. int e; int f; String chaine1,chaine; String M1,M2; int pos3; int pos4; int a,b; bool afficherForm = true; bool afficherForm1 = true; for(int i=1;i<Form4->StringGrid5->RowCount;i++) { if(Form4->StringGrid5->Cells[1][i]==Form2->ComboBox5->Text) { AnsiString chaine = Form4->StringGrid5->Cells[0][i]; afficherForm = false; if(int pos1 = chaine.Pos(Form2->ComboBox4->Text)) {afficherForm1 = false; chaine1= Form2->ComboBox2->Text; e=StrToInt(chaine1); chaine= Form4->StringGrid5->Cells[2][i]; M1=chaine.SubString(chaine.Pos("[")+1,(chaine.Pos(",")-chaine.Pos("["))-1); a=StrToInt(M1); M2= chaine.SubString(chaine.Pos(",")+1,(chaine.Pos("]")-chaine.Pos(","))-1); b=StrToInt(M2); if(e >= a&& e<= b) { Form7->Visible=true; } else { Form3->Visible=true; } } } } if(afficherForm) Form6->Show(); else if(afficherForm1) Form8->Show()
merci beaucoup pottierça marche bien .je veut maintenant ajouté a ce code les meme testes mé avec un StringGrid6 apres StringGrid7 j'ai essayé que changé mé ça marche pas est ce que j'ajout else? merci d'avance pour votre aide.
Salut,
je ne vois pas ce que tu veut faire avec ton StringGrid6 et StringGrid7
Désolé
bonjour ,dans mon projet j'ai 3 StringGrid (5,6,7) et il faut que je fé le meme teste pour les 3 StringGrid. on a fait le code que pour StringGrid 5 et il faut ajouté a ce code le meme travail pour 6 et7 .on tout cas merci beaucoup tu ma beaucoup aidé pour avancé dans mon projet.![]()
Et tu doit afficher exactement les même fenetre ? les StringGrid se trouvent-elles sur la même fenetre ?
Si c'est le cas, on peut faire une méthode générique :
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 int indexStringGrid; int e; int f; String chaine1,chaine; String M1,M2; int pos3; int pos4; int a,b; bool afficherForm; bool afficherForm1; TStringGrid * vectStringGrid[3] = {Form4->StringGrid5, Form4->StringGrid6, Form4->StringGrid7}; for(indexStringGrid=0;indexStringGrid<3;indexStringGrid++) { afficherForm = true; afficherForm1 = true; for(int i=1;i<vectStringGrid[indexStringGrid]->RowCount;i++) { if(vectStringGrid[indexStringGrid]->Cells[1][i]==Form2->ComboBox5->Text) { AnsiString chaine = vectStringGrid[indexStringGrid]->Cells[0][i]; afficherForm = false; if(int pos1 = chaine.Pos(Form2->ComboBox4->Text)) {afficherForm1 = false; chaine1= Form2->ComboBox2->Text; e=StrToInt(chaine1); chaine= vectStringGrid[indexStringGrid]->Cells[2][i]; M1=chaine.SubString(chaine.Pos("[")+1,(chaine.Pos(",")-chaine.Pos("["))-1); a=StrToInt(M1); M2= chaine.SubString(chaine.Pos(",")+1,(chaine.Pos("]")-chaine.Pos(","))-1); b=StrToInt(M2); if(e >= a&& e<= b) { Form7->Visible=true; } else { Form3->Visible=true; } } } } if(afficherForm) Form6->Show(); else if(afficherForm1) Form8->Show() }
salut , j'ai encore un probleme .quand par exemple je teste si
dans le cas ou elle est verifié dans le StringGrid5 elle s'affiche forme7 et non verifié dans StringGid6 s'affiche la forme 6.alors j'aurai 2 forme qui s'affiche en meme temp. si j' utilise un autre ComboBox3 et je teste si
Code : Sélectionner tout - Visualiser dans une fenêtre à part if(vectStringGrid[indexStringGrid]->Cells[1][i]==Form2->ComboBox5->Text)je fé le travail pour le StringGrid5 .
Code : Sélectionner tout - Visualiser dans une fenêtre à part if(Form2->ComboBox3->Text==Form4->Label1->Caption)
je fé le travail pour StringGrid6.
Code : Sélectionner tout - Visualiser dans une fenêtre à part if(Form2->ComboBox3->Text==Form4->Label2->Caption)
je fé le travail pour StringGrid7.
Code : Sélectionner tout - Visualiser dans une fenêtre à part if(Form2->ComboBox3->Text==Form4->Labe3->Caption)
ou on utilise un autre booléen dans le code?
merci d'avance pour votre aide.
Si tu veut qu'il y ai qu'une seul form d'affiché pour les trois StringGrid alors il faut modifier légèrement
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 int indexStringGrid; int e; int f; String chaine1,chaine; String M1,M2; int pos3; int pos4; int a,b; bool afficherForm = true; bool afficherForm1 = true; TStringGrid * vectStringGrid[3] = {Form4->StringGrid5, Form4->StringGrid6, Form4->StringGrid7}; for(indexStringGrid=0;indexStringGrid<3;indexStringGrid++) { for(int i=1;i<vectStringGrid[indexStringGrid]->RowCount;i++) { if(vectStringGrid[indexStringGrid]->Cells[1][i]==Form2->ComboBox5->Text) { AnsiString chaine = vectStringGrid[indexStringGrid]->Cells[0][i]; afficherForm = false; if(int pos1 = chaine.Pos(Form2->ComboBox4->Text)) {afficherForm1 = false; chaine1= Form2->ComboBox2->Text; e=StrToInt(chaine1); chaine= vectStringGrid[indexStringGrid]->Cells[2][i]; M1=chaine.SubString(chaine.Pos("[")+1,(chaine.Pos(",")-chaine.Pos("["))-1); a=StrToInt(M1); M2= chaine.SubString(chaine.Pos(",")+1,(chaine.Pos("]")-chaine.Pos(","))-1); b=StrToInt(M2); if(e >= a&& e<= b) { Form7->Visible=true; } else { Form3->Visible=true; } } } } } if(afficherForm) Form6->Show(); else if(afficherForm1) Form8->Show()
Salut !
Sans doute le faire avec une méthode prenant les objets cibles comme paramètres (a condition que le traitement soit identique d'une cible à l'autre).
Ca permettrait de simplifier l'écriture et aussi la lecture du code !!!
A plus !
merci beaucoup pottier ,j'ai bien avancé dans mon projet et tu ma donné une bonne idée.![]()
Partager