I ASSUME YOU USE DBGRID.
I have the same problem. I have not yet implemented the solution but this is the idea:
I made a table maintenance for my application, which uses a firebird database on a server. It is a form where there is a grid and some buttons. After I create an inherited form for each table I want to keep, therefore, desire an abstract design of this form. So the solution is to create the columns of the grid dinamically in the form's Create event.
Also I want the user to set the grid so as to see the columns you want by choosing a few available that do not have to match the columns in the table.
My idea is to create another table (or file ini / xml) with the information of the columns that display for each table used by the application and another table (or file ini / xml) in which to save user settings.
for example, a table called "Items", with these fields
ID
Description
Unit
Price
Join Date
Date Modified
I want to look at grid
Description
Unit
Price
to get what we want, we will have a table "Available Fields" that has these fields:
User
TableName
FieldName
ColumnTitle
Visible
....
This table will be recorded this data:
TableName | Idx | FieldName | ColumnTitle | Visible |
------------ | -------------- | --------------------- | --------------------- | ------- |
Items | 0 | Description | Item Description | True |
Items | 1 | Unit | ut | True |
Items | 2 | Price | Price | True |
... and the other table....
User | TableName | Idx | Col | Width | Visible |
------ | ------------ | ------ | ------ | ------- | ------- |
* | Items | 0 | 0 | 100 | True |
* | Items | 1 | 1 | 100 | True |
* | Items | 2 | 2 | 100 | True |
Pepe | Items | 0 | 0 | 100 | True |
Pepe | Items | 1 | 1 | 100 | False |
Pepe | Items | 2 | 2 | 50 | True |
where * in second table means "default configuration".
User "Pepe" see first and third column , and he changed the withd of the third.....
When the form is created, I create the columns according to the default (*) and then apply the changes for the user.
As I said, I have not yet implemented, therefore certain that requires some tinkering.
I hope that fits, at least for inspiration.