Link to home
Start Free TrialLog in
Avatar of rpetruni
rpetruni

asked on

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
Avatar of Motaz
Motaz

I can't understand your quesion, what exactly did you want to do ?
why did you want to do this ?
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;
more explain !!
ASKER CERTIFIED SOLUTION
Avatar of Ronald Buster
Ronald Buster
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rpetruni

ASKER

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