TDBGrid

How can I make a column of a DBGrid invisible? (D2).

I guess this question should be easy, but I can't find it.
LVL 8
ZifNabAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MatveyCommented:
You should call the field editor and set the field's visible property (Table component).

Matvey
0
julio011597Commented:
You may want to have a look at the "Columns" property of TDBGrid, which is an object of type TDBGridColumns.

The oddity is that TDBGridColumns has an Add() method to add one new column, while has just a Clear method to remove _all_ the columns (BTW, no way to "hide" a column: you can just remove).

I had a look at TCollection which is TDBGridColumns' parent and it has a RemoveItem procedure, but it is private, so you'd do a lot of work to work it around.

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZifNabAuthor Commented:
Matvey, I did this, but it's not so good. If you make field 4 invisible than every field behind this field changes in number. So field 5, becomes 4, 6 becomes 5. (Not good if you want to call one field back visible). If I could call the fields by name it could be so much better. Besides, if I do it this way, I have to make every format of the columns by code. I don't want that. I'm too lazy...

Julio,
Yep, no hide available, that's the truth. That's why I'm asking this question. I thougt to hide them with width=0, but then if you have columnlines on, these lines still are visible.

Isn't there a component out there? (Matvey, thank you for the link to the activeX component. But it's way too expensive for me)

0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

MatveyCommented:
You know what -try setting the grid's fields[i] visible property, I think it does the work, but I didn't try it.
0
ZifNabAuthor Commented:
That's just the problem : Look comment above. If fields visible property is set to false, all indexes change!
0
julio011597Commented:
I'm sorry i cannot point you to any components i know; anyway, on the Delphi Super Page, there are _lots_ of improved DBGrids (it seems to be the preferred topic), so it could be worth having a look there.
0
MatveyCommented:
When you make a TField invisible the indexes change inside DBGrid.Fields, but NOT in Table.Fields!
0
ZifNabAuthor Commented:
Matvey, I can't use The table.Fields property to set visible true or false. I use the same table for other displays at the same time for the same fields.
0
MatveyCommented:
Hmmm, maybe you can use several Table objects -I don't hink it's taht bad...
0
millerwCommented:
If you don't assign columns to your DBGrid, you can use the Field Editor to assign the VISIBLE property to a particular field.  This will turn them on and off for your grid as long as you have no specific columns defined.

Probabaly not what you want, but thought you should know,
Scott
0
millerwCommented:
Forget that post, DUH--I'm just tired---been a long week

You have already tried that I see.

Sorry again,
Scott
0
tmhstwCommented:
form->myListGrid->Columns->Items[0]->Visible = false
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.