tags:

views:

260

answers:

3

how can i create dbgrid with composite columns,

example :dbgrid header | name | | first | last |

+1  A: 

The composition should/has to be done on the dataset (table).
If you use a SQL Selects for getting your data, you shoud make the "composition" in the select statement (syntax depends of the data engine/sql server).
You can also make a calculated field on the datasset (look in help and in the examples installed with delphi.

BennyBechDk
thanks a lotbut i am not trying to make (lookup or calculated ) field, i want simply to see fields (columns) grouped by major titles, to be well presented in the dbgrid.exampleColumns first name ,last name,sex..with "person" titleColumns job,salary,...with "professional" title
khelifaadm
A: 

Standard Delphi DBGrid does not support such feature except for Aggregate field type which is supported only in ClientDataset.

You can use 3rd-party grid components that provide such functionality. I personally like EhLib grid which provides this feature, and lots of other ones. Here is a screenshot of EhLib with nested column headers:

alt text

You can see other screenshots in this link: http://www.ehlib.com/dbgrideh1.htm

vcldeveloper
Thank you very much for your clear and useful answer
khelifaadm
A: 

You can get such functionality by coding:

  1. Subclassing a DBGrid
  2. Virtual TreeView you write the DB access stuff (there are examples on the site), and manage the custom drawing

Or by paying:

  1. DevExpress is my choice, amazing grids.
  2. Any other third party grid like the one mentioned EHLib...
Mihaela