Board index » delphi » DBGrid Columns in Delphi 1

DBGrid Columns in Delphi 1

How do I access the Columns in the DBGrid in Delphi 1?  For instance, I need
access to a field, but I don't want to display it in the DBGrid.  Take the
Following:
Invoice Header TTable contains fields INV#, INVDATE, CUSTACCT, etc .
Invoice Detail TTable contains INV #, ITEM #, DESCRIPT, PRICE, QTY.

I don't want to display the INV# field in the DBGRID for the invoice
details, but I need access to it for the relation between the Header file
and the Detail file.  Right now, the only way I have found not to display
the Invoice # in the DBGrid for the Invoice details is to omit it from the
fields list for the TTable.  But then, I can't relate the Header & Detail
files.

There's got to be a better way to do this.  Any hints?

Thanks,
Jesse

 

Re:DBGrid Columns in Delphi 1


Hi there.

Quote
Jesse Castleberry wrote:
> How do I access the Columns in the DBGrid in Delphi 1?  For instance, I need
> access to a field, but I don't want to display it in the DBGrid.  Take the
> Following:
> Invoice Header TTable contains fields INV#, INVDATE, CUSTACCT, etc .
> Invoice Detail TTable contains INV #, ITEM #, DESCRIPT, PRICE, QTY.

> I don't want to display the INV# field in the DBGRID for the invoice
> details, but I need access to it for the relation between the Header file
> and the Detail file.  Right now, the only way I have found not to display
> the Invoice # in the DBGrid for the Invoice details is to omit it from the
> fields list for the TTable.  But then, I can't relate the Header & Detail
> files.

You do not need to eliminate fields from the fields list. You should better edit
the columns of the DBGrid. Either right-click on the DBGrid and 'Columns
editor...' item or click an ellipsis button in the Object Inspector for the
Columns property. You will get a dialog box whithin that it is possible to
remove a redundant column. That is all!
Quote
> There's got to be a better way to do this.  Any hints?

> Thanks,
> Jesse

Re:DBGrid Columns in Delphi 1


Quote
>You do not need to eliminate fields from the fields list. You should better
edit
>the columns of the DBGrid. Either right-click on the DBGrid and 'Columns
>editor...' item or click an ellipsis button in the Object Inspector for the
>Columns property. You will get a dialog box whithin that it is possible to
>remove a redundant column. That is all!

In Delphi 3 & perhaps Delphi 2, that works great, but in Delphi 1, there
doesn't appear to be a Columns property.  If I right click, there is no
"Columns Editor", and in the Object Inspector, there is no Columns property
available for me to click on ???

Jesse

Re:DBGrid Columns in Delphi 1


In article <6cbr84$m0...@news9.ispnews.com>, Jesse Castleberry
<D...@iThink.net> writes

Quote
>>You do not need to eliminate fields from the fields list. You should better
>edit
>>the columns of the DBGrid. Either right-click on the DBGrid and 'Columns
>>editor...' item or click an ellipsis button in the Object Inspector for the
>>Columns property. You will get a dialog box whithin that it is possible to
>>remove a redundant column. That is all!

>In Delphi 3 & perhaps Delphi 2, that works great, but in Delphi 1, there
>doesn't appear to be a Columns property.  If I right click, there is no
>"Columns Editor", and in the Object Inspector, there is no Columns property
>available for me to click on ???

>Jesse

Just set the "visible" property of the field you don't want in the grid
to false.

--
Ian Dunn                     I...@polyhedron.com

Polyhedron Software Ltd.        
Programs for Programmers - QA, Compilers, Graphics

************ Visit our Web site on http://www.polyhedron.co.uk/ ************

Re:DBGrid Columns in Delphi 1


Hi, Jesse.

Quote
Jesse Castleberry wrote:
> >You do not need to eliminate fields from the fields list. You should better
> edit
> >the columns of the DBGrid. Either right-click on the DBGrid and 'Columns
> >editor...' item or click an ellipsis button in the Object Inspector for the
> >Columns property. You will get a dialog box whithin that it is possible to
> >remove a redundant column. That is all!

> In Delphi 3 & perhaps Delphi 2, that works great, but in Delphi 1, there
> doesn't appear to be a Columns property.  If I right click, there is no
> "Columns Editor", and in the Object Inspector, there is no Columns property
> available for me to click on ???

> Jesse

  I'm sorry, I did not know that D1 does not support the 'Columns' property of
the DBGrid. But there is one more idea: TField object has the Visible property
(at least in D2). In the help I've found a reference: "To hide a field in a data
grid, set Visible to False. If Visible is True, the field appears in the grid".
Therefore there is a propose:
1. Create AfterOpen event handler of your dataset.
2. Within the handler body use the code:
    ATable.FieldByName('INV#').Visible:= false.
Maybe that will work in D1.
Wishing you the victory.
Edward.

Other Threads