Bonjours,
Je cherche à trouver un tableau comme avec Control->Find est-ce possible.
Merci d'avance.Code:array<Control ^> ^labelATrouverHeure = Controls->Find(String::Format("label{0}",i), true);
TrollTop
Version imprimable
Bonjours,
Je cherche à trouver un tableau comme avec Control->Find est-ce possible.
Merci d'avance.Code:array<Control ^> ^labelATrouverHeure = Controls->Find(String::Format("label{0}",i), true);
TrollTop
Ton tableau est-il un contrôle?
non c'est des tableaux déclarer
On peut faire des tableaux comme un Control ex TextBox ou LabelCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 private:static array<String ^,2> ^TableauContainer1 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauContainer2 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauContainer3 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauContainer4 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauContainer5 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauContainer6 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauContainer7 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte1 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte2 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte3 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte4 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte5 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte6 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte7 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte8 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte9 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte10 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte11 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte12 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte13 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte14 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte15 = gcnew array<String ^,2> (4,1000); private:static array<String ^,2> ^TableauPorte16 = gcnew array<String ^,2> (4,1000);
Merci pour ton aide
TrollTop
Si ces tableaux ne sont pas dans la liste Controls, tu ne peux pas les avoir avec Controls.Find.
Par contre, tu peux toujours te faire un dictionnaire de tableaux de strings à deux dimensions...
PS: Pourquoi sont-ils déclarés static?
Comment tu fais pour les mettre dans la liste de control ou bien faire un dictionnaire ?
Merci
TrollTop
Et tu peux même t'en faire une boucle for:Code:
1
2
3
4 Dictionary< String^, array<String^, 2>^ >^ dico = gcnew Dictionary< String^, array<String^, 2>^ >(); dico->Add(L"TableauContainer1", gcnew array<String^, 2> (4,1000)); dico->Add(L"TableauContainer2", gcnew array<String^, 2> (4,1000)); ...
Code:
1
2
3 Dictionary< String^, array<String^, 2>^ >^ dico = gcnew Dictionary< String^, array<String^, 2>^ >(); for(int i=1 ; i<=7 ; i++) dico->Add(String::Format(L"TableauContainer{0}", i), gcnew array<String^, 2> (4,1000));
Ou encore, tu peux te faire un tableau de tableaux à la place:
Code:
1
2 array< array<String^, 2>^, 1 >^ TableauxContainer = gcnew array< array<String^, 2>^, 1 >(7); array< array<String^, 2>^, 1 >^ TableauxPorte = gcnew array< array<String^, 2>^, 1 >(16);
pour le premier sa fonctionne pas erreur
1>d:\visual studio 2008\inventaire\inventaire\Form1.h(1564) : error C2143: erreur de syntaxe*: absence de ';' avant '<'Code:Dictionary< String^, array<String^, 2>^ >^ dico = gcnew Dictionary< String^, array<String^, 2>^ >();
1>d:\visual studio 2008\inventaire\inventaire\Form1.h(1564) : error C4430: spécificateur de type manquant - int est pris en compte par défaut. Remarque*: C++ ne prend pas en charge int par défaut
1>d:\visual studio 2008\inventaire\inventaire\Form1.h(1564) : error C2238: jetons inattendus avant ';'
pour le deuxième exemple tu déclare la grosseur du tableau où ?
et comment l'appelle tu dans la procédure ?
MerciCode:
1
2 array< array<String^, 2>^, 1 >^ TableauContainer = gcnew array< array<String^, 2>^, 1 >(7); array< array<String^, 2>^, 1 >^ TableauPorte = gcnew array< array<String^, 2>^, 1 >(16);
TrollTop
Pour le dictionary, essaie peut-être en précisant qu'il fait partie du namespace System::Collections::Generic.
Pour le tableau, regarde la fin des lignes (utilise la scrollbar). Tu y verras la taille des tableaux.
Et ça s'utilise ainsi:
Code:
1
2 int i = ... array<String^, 2>^ tabContI = TableauxContainer[i-1];
pour le tableau tu as juste écrit (7) et (16) tandis que moi c (4,1000)
le 7 c'est le nombre de tableaucontainer et 16 le nombre de tableauPorte
mais il y a pas la grosseur comme (4,1000)
TrollTop
Il faut les instancier séparément:
Code:
1
2 for(int i=0 ; i<TableauxContainer->Length ; i++) TableauxContainer[i] = gcnew gcnew array<String^, 2> (4,1000);
Sinon, tu peux aussi carrément te faire un tableau à trois dimensions...
Caline j'avais pas pensé à ça un tableau 3 dimensions ca fonctionne merci beaucoup pour ton aide si précieuse.
bye bye @+
TrollTop