Solved

DBgrid columns delete

Posted on 1997-10-23
4
837 Views
Last Modified: 2010-04-04
I want to delete a columns in a DBgrid with Delphi2 in run-time mode.
Add a columns is possible : DBgrid.columns.add
This command add a columns at the end of the dbgrid.
How to delete this last columns ?
The command DBgrid.columns.del or erase don't work.
Thanks.
0
Comment
Question by:lgc5800
4 Comments
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1348738
Lgc,

As opposed to actually deleting the column, how about just setting it's visible property to FALSE, thereby hiding it but keeping it "available" for program usage or possible re-display later?

DBGrid.Columns[2].Visible := False;

Good luck with your project!
Pegasus
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1348739
Sorry, but DBgrid.columns.visible := false and RebuildColumns don't work with persistant field in my program.
Thanks Pegasus and Zifnab.

0
 

Author Comment

by:lgc5800
ID: 1348740
1. Place a DBGrid on a form.
2. Place a button on a form.
3. Connect the DBGrid to a table that has more then 2 fields.
4. Set Table's Active to true.
5. Write the following code, that deletes the second column:

procedure TForm1.Button1Click(Sender: TObject);
begin
  DBGrid1.Columns.RebuildColumns;
  DBGrid1.Columns.Items[1].Destroy;
end;

0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 200 total points
ID: 1348741
Thanks RONIT you have the response for my problem.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

816 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

8 Experts available now in Live!

Get 1:1 Help Now