LiveGrid: opening Query on the fly

Hello,


I have a form on which a Livegrid is bound to a Query.
I crate the form and change the query at runtime to display different data tables.

e.g.

Query.Sql.Clear;
Query.Sql.Add('select customer_autoinc,customer_name,customer_phone from  customer');
Query.Sql.Add('order by customer_name');
Query.Open;

My problems are with this approach so far:

-The first row of the Livegrid starts with the first record. There is no caption for the fields.

-Although in the select there is the customer_autoinc field, I don't want to show it to the user.
I couldn't find column.visible property to hide it.

Thank you very much for your help!



Hi, 


Livebindings operates differently, the visibility is managed by a LinkGridToDataSource component that allows defining which column are visible. The caption / header can be set there as well. To know how to create a LinkGridToDataSource, please first use the LiveBindings wizard. When the connection is setup, you can still programmatically change the query.
Hi Pieter,

Thank you for your answer. I managed not to show unwanted fields like this:

     LinkGridToDataSource.Columns.Clear;
     With LinkGridToDataSource.Columns.Add Do
      Begin
        Header := 'Customer';
        MemberName := 'customer_name';
      End;

But this problem hasn't resolved:
"The first row of the Livegrid starts with the first record. There is no caption for the fields."
So it should be like this:
Customer
Joe Dove
Fred Aster

and instead it is like this:
Joe Dove
Fred Aster

I am fairly sure it must be some simple setting, but I don't know which.
Would you be so kind to help me? Thank you very much.

Do you have grid.FixedRows = 1 ?

Thank you, Bruno!

It works. :-)