begin process at 2012 02 08 09:17:13
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Maths

 > CREER DYNAMIQUEMENT PLUSIEURS STRINGGRID

CREER DYNAMIQUEMENT PLUSIEURS STRINGGRID


 Information sur la source

Note :
Aucune note
Catégorie :Maths Niveau :Débutant Date de création :18/04/2003 Date de mise à jour :18/04/2003 11:25:52 Vu :5 923

Auteur : ryadus

Ecrire un message privé
Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note

 Description

Ce code permet de créer dynamiquement autant de StringGrid qu'on veut rien qu'on entrant le nombre et on cliquant sur le bouton;

Source

  • procedure TForm1.Button1Click(Sender: TObject);
  • var i,n:integer;
  • Mat : TStringGrid;
  • begin
  • n:=strtoint(edit1.text);
  • for i:=1 to n do
  • TStringGrid(FindComponent('Mat'+inttostr(i))).free; //pour effacer les stringgrid existant
  • Mat := TStringGrid.Create(self);
  • Mat.Parent := Self;
  • Mat.Name := 'Mat1';
  • Mat.Width := 235;
  • Mat.Height := 130;
  • Mat.Left := 18;
  • Mat.Top := 30;
  • Mat.Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing,goTabs];
  • Mat.DefaultColWidth :=45;
  • Mat := TStringGrid.Create(self);
  • Mat.Parent := Self;
  • Mat.Name := 'Mat2';
  • Mat.Width := 235;
  • Mat.Height := 130;
  • Mat.Left := 280;
  • Mat.Top := 30;
  • Mat.Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing,goTabs];
  • Mat.DefaultColWidth :=45;
  • i:=3;
  • while (i<= n) do
  • begin Mat := TStringGrid.Create(self);
  • Mat.Parent := Self;
  • Mat.Name := 'Mat'+inttostr(i); // un nom différent pour chaque stringgrid créer
  • Mat.Width := 235;
  • Mat.Height := 130;
  • Mat.Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing,goTabs];
  • Mat.DefaultColWidth :=45;
  • if ((i mod 2) = 0) then
  • begin Mat.Left := 280;
  • Mat.Top:= TStringGrid(FindComponent('Mat'+inttostr(i-2))).Top+TStringGrid(FindComponent('Mat'+inttostr(i-2))).Height+10;
  • end
  • else begin Mat.Left := 18;
  • Mat.Top := TStringGrid(FindComponent('Mat'+inttostr(i-2))).Top+TStringGrid(FindComponent('Mat'+inttostr(i-2))).Height+10;
  • end;
  • i:=i+1;
  • end;
  • end;
procedure TForm1.Button1Click(Sender: TObject);
var       i,n:integer;
          Mat : TStringGrid;
begin
n:=strtoint(edit1.text);
for i:=1 to n do
 TStringGrid(FindComponent('Mat'+inttostr(i))).free; //pour effacer les stringgrid existant

Mat := TStringGrid.Create(self);
Mat.Parent := Self;
Mat.Name := 'Mat1';
Mat.Width := 235;
Mat.Height := 130;
Mat.Left := 18;
Mat.Top := 30;
Mat.Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing,goTabs];
Mat.DefaultColWidth :=45;

Mat := TStringGrid.Create(self);
Mat.Parent := Self;
Mat.Name := 'Mat2';
Mat.Width := 235;
Mat.Height := 130;
Mat.Left := 280;
Mat.Top := 30;
Mat.Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing,goTabs];
Mat.DefaultColWidth :=45;

i:=3;
while (i<= n) do
begin Mat := TStringGrid.Create(self);
      Mat.Parent := Self;
      Mat.Name := 'Mat'+inttostr(i);  // un nom différent pour chaque stringgrid créer
      Mat.Width := 235;
      Mat.Height := 130;
      Mat.Options := [goFixedVertLine,goFixedHorzLine,goVertLine,goHorzLine,goRangeSelect,goEditing,goTabs];
      Mat.DefaultColWidth :=45;
       if ((i mod 2) = 0) then
         begin Mat.Left := 280;
               Mat.Top:= TStringGrid(FindComponent('Mat'+inttostr(i-2))).Top+TStringGrid(FindComponent('Mat'+inttostr(i-2))).Height+10;
         end
       else begin  Mat.Left := 18;
                   Mat.Top := TStringGrid(FindComponent('Mat'+inttostr(i-2))).Top+TStringGrid(FindComponent('Mat'+inttostr(i-2))).Height+10;
            end;

      i:=i+1;
end;

end;

 Conclusion

Je créer d'abord 2 StringGrid comme réference, et je créer les autres par rapport à la poisition des 2 premiers, car ma dsposition est 2 par ligne;


 Sources du même auteur

Source avec Zip STRINGGRID EDIT
Source avec Zip CHERCHE ET EFFACE
TCHART ET TROP DE SERIES

 Sources de la même categorie

Source avec Zip Source avec une capture RESOLUTION EQUATIONS DEGRE "N" + CALCULETTE SCIENTIFIQUE par pseudo3
Source avec Zip DEUX BIBLIOTHÈQUES POUR CALCULER AVEC DES ENTIERS TRÈS GRAND... par Rekin85
Source avec Zip Source avec une capture MOTEUR PHYSIQUE 2D CHIPMUNK.. EN DELPHI! par Bacterius
Source avec Zip Source avec une capture TABLEAU DE KARNAUGH par ADMR
Source avec Zip Source avec une capture FILTRAGE NUMÉRIQUE IIR par Pouillerot

Commentaires et avis

Commentaire de Adkiks le 21/07/2004 20:29:12

Ce n'est pas un avis ,mais plutot une demande d'aide.Voilà!Je prépare mon diplome de Technitien supérieur en informatique de gestion,actuellement je travaille sur mon logiciel.J'utilise un stringgrid poua la saisie des documents.le probleme c'est que pour les controles des champs il faut taper ENTREE por qu'il y est un controle sur ce champ ,alors que je veux déclencher le controle avec d'autres touches (par éxemple TABULATION ou FLECHES de DIRECTION).J'espère  avoir une réponse .Merci !!

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,515 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales