Re: StringGrids and Multiple Forms

Posted by Willy on March 29, 2007

In Reply to StringGrids and Multiple Forms posted by Paul Collings on March 23, 2007

: I have 2 forms within my programme. A series of buttons on form1 and a StringGrid on form2. I want to link the 2 forms so that each time I click a button in Form1 an event occurs within the StringGrid on Form2. I've played about with tab components but can't get it to work.
-----------------------

For accessing stuff on another form, you "prefix" it with the name of that form, followed by a dot. E.g. if the grid is named StringGrid1, then this becomes Form2.StringGrid1.Example:

Form2.StringGrid1.Color := clYellow;

The unit for Form1 has to know where to find Form2, therefore add a "uses unit2" to the code, immediately after the line with "implementation":

unit Unit1;
interface
...
[and so on...]
implementation
uses Unit2;

Related articles

       

Follow Ups