Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating string grid non-visually

120 views
Skip to first unread message

Peter Montgomery

unread,
Feb 23, 1998, 3:00:00 AM2/23/98
to

I am trying to create a string grid component in a Delphi 2.0 program in
a non-visual fashion. In other words, I want to pass a function a string
grid, and then make a local copy of it and all the data it has. Since
grids are actually passed as pointers, I need to use the "create" method.
In the help file, it says you can pass it "self" as the owner if you
don't want a form to own it. However, this doesn't work and Delphi just
claims that "self" hasn't been declared. Typical of the Delphi Help
files, there is no other information on the word "self" in the files.
Can anyone explain to me how I can have a procedure create a string grid
for its own use? Also, is there any simple way to copy the data other
than via the "cells" method?

Thanks,
PeterM
--
Delete "xyz" for email reply

Roman Krejci

unread,
Feb 24, 1998, 3:00:00 AM2/24/98
to

Hi Peter,
the Owner parameter in the create constructor should be the component that
"owns" the created component. The ownership means, among others, that the
created component
is destroyed when the owner is destroyed. Because the components are usually
created within Form methods, the parameter is almost allways SELF, which
means
the instance of the form that called the method.
Generally - SELF is defined only within methods of CLASSes (or objects) and
represents
the instance of the class (object) that called the method.
Nothing in the world, however, can prevent you from setting the owner to
whatever
component you want: MyGrid := tStringGrid.Create(Application.mainform) for
example.
After creating the grid, don't forget to set its parent before setting all
other properties. The parent property should be the wincontrol on the top of
which the grid should actually
appear - some panel for example.
As to the question of copying data from one grid to another, I am afraid
that you will need to
iterate through cells, which is not much of code anyway.
--
Roman
KRE...@mbox.cesnet.cz
(please remove STOPSPAM. in header]
Peter Montgomery wrote in message ...

Peter Montgomery

unread,
Feb 24, 1998, 3:00:00 AM2/24/98
to

In article <6cua60$k3...@forums.borland.com>,
STOPSPA...@MBOX.CESNET.CZ says...
> Hi Peter,
> ...don't forget to set its parent before setting all
> other properties....

Roman,
Thanks. I think you not only answered my question, but solved
another problem I had. After posting to this newsgroup. I decided to go
ahead and give the object an owner, but then I kept getting messages
saying the object had no parent. Since it was late, I was equating the
two (owner/parent) as the same. I'm going to try setting the parent now
and see what happens.

0 new messages