Accueil > > > CREER DYNAMIQUEMENT PLUSIEURS STRINGGRID
CREER DYNAMIQUEMENT PLUSIEURS STRINGGRID
Information sur la source
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
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|