• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

creating dbgrid columns at running time

hello,
I cant  create dbgrib columns at running time,
Do any sample that describe it for  me,
 I need these features for my dbgrid columns
1:the change of header column
2:decreament the dataset fields(show less than dataset fields)

any one have a sample for this work?

Thanks
m.reza
0
Imbeginner
Asked:
Imbeginner
1 Solution
 
HardiCommented:
Hi

You can access each column using DBGrid1.Columns[index]
For example:
DBGrid1.Columns[0].Title.Caption := 'First';
DBGrid1.Columns[1].Visible := False;

Does that help?
0
 
da-vinciCommented:
Also creating is quite easy:

Delphi syntax:
function Add: TColumn;

Description
Add returns the new column.

After you have created the new column you can edit any property you like by using the index.
The column you added has always the following itemindex:
DBGrid1.Columns[DBGrid1.Columns.Count-1]

0
 
ginsonicCommented:
Simple:

Grid1.Columns.Add.FieldName:='MyColumn'; // My name
Grid1.Columns.Add.Width:=250;  //My width
0
 
ImbeginnerAuthor Commented:
thanks for your good answer
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now