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

Saving DBGrid Column Width

0 views
Skip to first unread message

Richard Tully

unread,
Feb 14, 2001, 1:39:08 AM2/14/01
to
I am trying to save the column widths of a grid to the registry so that the
user will have the same column widths when they next open the form.
I seem to be able to get access to CustomDBGrid.Columns[i].Width
or CustomDBGrid.DataSource.DataSet.Fields[i].DisplayWidth
from within the form, but when using a component to do this the properties
are no longer visible
(DBGrid1 as TCustomDBGrid).Columns[i].Width)
Does anyone have any suggestions ?


Ken White

unread,
Feb 14, 2001, 10:00:35 AM2/14/01
to
Hi Richard,

> from within the form, but when using a component to do this the properties
> are no longer visible
> (DBGrid1 as TCustomDBGrid).Columns[i].Width)
> Does anyone have any suggestions ?

I'd add a field to your component, something like

protected
FGrid: TDBGrid;

and set the grid:
published
Grid: TDBGrid read FGrid write FGrid;

Then, before saving the grid column widths, assign the
grid to the component:

MyComponent.Grid := DBGrid1;
with MyComponent.Grid do
begin
// Save the columns here
end;

HTH,

Ken
--
Ken White

Clipper Functions for Delphi
http://www.adpsi.com

Peter Below (TeamB)

unread,
Feb 17, 2001, 11:28:34 AM2/17/01
to

Well, yes. Do not cast to TCustomDBGrid, cast to TDBGrid, if you need to cast
at all. The TCustom classes you find in the VCL do not publish any properties
and have many things as protected that is than published by descendents.

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

0 new messages