Solved

TDBGrid

Posted on 1998-01-15
12
244 Views
Last Modified: 2010-04-04
How can I make a column of a DBGrid invisible? (D2).

I guess this question should be easy, but I can't find it.
0
Comment
Question by:ZifNab
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1356732
You should call the field editor and set the field's visible property (Table component).

Matvey
0
 
LVL 5

Accepted Solution

by:
julio011597 earned 10 total points
ID: 1356733
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
 
LVL 8

Author Comment

by:ZifNab
ID: 1356734
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
 
LVL 3

Expert Comment

by:Matvey
ID: 1356735
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
 
LVL 8

Author Comment

by:ZifNab
ID: 1356736
That's just the problem : Look comment above. If fields visible property is set to false, all indexes change!
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1356737
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:Matvey
ID: 1356738
When you make a TField invisible the indexes change inside DBGrid.Fields, but NOT in Table.Fields!
0
 
LVL 8

Author Comment

by:ZifNab
ID: 1356739
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
 
LVL 3

Expert Comment

by:Matvey
ID: 1356740
Hmmm, maybe you can use several Table objects -I don't hink it's taht bad...
0
 
LVL 1

Expert Comment

by:millerw
ID: 1356741
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
 
LVL 1

Expert Comment

by:millerw
ID: 1356742
Forget that post, DUH--I'm just tired---been a long week

You have already tried that I see.

Sorry again,
Scott
0
 

Expert Comment

by:tmhstw
ID: 7531249
form->myListGrid->Columns->Items[0]->Visible = false
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IdTelnet1DataAvailable handler freezes the Application 4 62
Delphi OLE Error 8 93
Intraweb download file link ? 1 105
Delphi: Connect to running MS Outlook 4 47
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now