Link to home
Start Free TrialLog in
Avatar of ZifNab
ZifNab

asked on

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.
Avatar of Matvey
Matvey

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

Matvey
ASKER CERTIFIED SOLUTION
Avatar of julio011597
julio011597

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ZifNab

ASKER

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)

You know what -try setting the grid's fields[i] visible property, I think it does the work, but I didn't try it.
Avatar of ZifNab

ASKER

That's just the problem : Look comment above. If fields visible property is set to false, all indexes change!
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.
When you make a TField invisible the indexes change inside DBGrid.Fields, but NOT in Table.Fields!
Avatar of ZifNab

ASKER

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.
Hmmm, maybe you can use several Table objects -I don't hink it's taht bad...
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
Forget that post, DUH--I'm just tired---been a long week

You have already tried that I see.

Sorry again,
Scott
form->myListGrid->Columns->Items[0]->Visible = false