begin process at 2010 02 10 03:51:42
  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 :4 136

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 CONVERTISSEUR D'UN NOMBRE DÉCIMAL EN BINAIRE ET HEXADECIMAL par ludokk
Source avec Zip Source avec une capture PREMIER OU PAS? par ludokk
Source avec Zip Source avec une capture CONJECTURE DU CARRÉ DES FACTEURS par Bacterius
Source avec Zip Source avec une capture GÉNÉRATEUR DE NOMBRES PSEUDO-ALÉATOIRES par Bacterius
Source avec Zip Source avec une capture ALGORITHME DE HASH LEA par Bacterius

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...

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
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,546 sec (3)

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