Board index » delphi » Runtime DBGrid Columns

Runtime DBGrid Columns

Using D3, I would like to display a selected TColumn(s) in a DBGrid at
runtime.  I don't have much experience using the DBGrid.

For example, in a small DB I would be displaying 3 columns of 20, but maybe
I want to add a column during runtime by the click of a button.  I haven't
seen a method to add a column and I can display any 3 columns I like, but I
can't add or remove.  What am I doing wrong???

Thanks in advance, Please email me and post too.

David Godfrey
dgodf...@pgmusic.com

 

Re:Runtime DBGrid Columns


var
  ThisColumn: TColumn;
begin
  ThisColumn := dbGrid1.Columns.Add;
  ThisColumn.FieldName := 'afieldname';
  ThisColumn.Title.Caption := 'New Column';
etc.

Quote
> For example, in a small DB I would be displaying 3 columns of 20, but maybe
> I want to add a column during runtime by the click of a button.

Other Threads