how to do this?

Lets say that i have a procedure like this one:

Form1.DBGrid.......something

and i would like to do this:

aa: some variable;

aa.DBGrid1...., where aa if Form1

and later this:

bb: some variable;

aa.bb... something where aa is form1, and bb is dbgrid1

is it possible and how?
Thanks
                   Robert
LVL 1
rpetruniAsked:
Who is Participating?
 
Ronald BusterConnect With a Mentor OwnerCommented:
Yes this is possible :

In property inspector change names of

form1 in aa
dbgrid1 in bb

after that you can use

aa.bb :=

regards,

Cono
0
 
MotazCommented:
I can't understand your quesion, what exactly did you want to do ?
0
 
MotazCommented:
why did you want to do this ?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
kifahCommented:
Hi,
YES Just do the follwoing

Type
  Form1 = ......
  .
  .
  .
  Private
  Public
    BB: TDBGrid;
 end;

var
  aa: TForm;
Imp.....

Procedure XYZ........
begin
  aa := Form1;
  aa.bb.ZZZZZZ :=
end;
0
 
bakry99Commented:
more explain !!
0
 
rpetruniAuthor Commented:
to Motaz and bakry99:
i want to do this:
procedure TOsnovnaForma.Snimi(Ime:String; broj:Integer;Sender:TObject);
var
   i: Integer;
   IniZaKolone : TIniFile;
begin
     IniZaKolone:=TIniFile.Create(RadniDirektorij + Ime + '.ini');
     for i:=0 to broj - 1 do
     begin
          IniZaKolone.WriteString(Ime, 'Polje: ' + IntToStr(i), SomeForm.DBGrid1.Columns[i].FieldName);
          IniZaKolone.WriteString(Ime, 'Naslov: ' + IntToStr(i), SomeForm.DBGrid1.Columns[i].Title.Caption);
          IniZaKolone.WriteString(Ime, 'Sirina: ' + IntToStr(i), IntToStr(SomeForm.DBGrid1.Columns[i].Width));
     end;
end;
!!! I want  some form, and DBGrid1 to be varible - i want to call this procedure from lots of forms !!!
To cono :
:-)
To cifah:
Your explanation is ok, but only if i try to call this procedure from this form, i need to call it from other forms, and in this situation i don't have acces to components on the form. How to achieve this?  
                         Robert
0
 
rwilson032697Commented:
You can write your procedure like this:

procedure TOsnovnaForma.Snimi(Ime:String; broj:Integer;Sender:TObject;
TheGrid : TDBGrid);
var
   i: Integer;
   IniZaKolone : TIniFile;
begin
     IniZaKolone:=TIniFile.Create(RadniDirektorij + Ime + '.ini');
     for i:=0 to broj - 1 do
     begin
          IniZaKolone.WriteString(Ime, 'Polje: ' + IntToStr(i), TheGrid.Columns[i].FieldName);
          IniZaKolone.WriteString(Ime, 'Naslov: ' + IntToStr(i), TheGrid.Columns[i].Title.Caption);
          IniZaKolone.WriteString(Ime, 'Sirina: ' + IntToStr(i), IntToStr(TheGrid.Columns[i].Width));
     end;
end;

Then just pass the DBGrid from the form when you call the funcTrion.

Cheers,

Raymond.
0
 
rpetruniAuthor Commented:
Thanks rwilson
0
All Courses

From novice to tech pro — start learning today.