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

Create Components on the fly

Using delphi I have a combobox which has a list of departments the user selects the appropriate department, when this is done a database is accessed and should list all the people in the department and provide an input field for each person in the department to capture some data to be returned to the database, there are varying numbers of people in each department. Would this be an area when I would create a series of components on the fly? if so how would I do this

Thanks

Jake
0
elschott
Asked:
elschott
  • 2
3 Solutions
 
rfwoolfCommented:
Hopefully someone will come along and explain how to do that,
but in the meantime, have you considered a DBGrid and connecting it to a Query (SQL) ?
In the query you can fetch all records but only the fields/columns that you want the user to see.
Then if the DBGrid is connected to the Query, the results will show in the DBGrid, and here's the important part:
It will show the information you want, and they'll just be able to click on a cell they want to over-write and just type in the new information.

Of course this comes with some common problems:
* Calling post. After the person has finished typing in a cell, they have to call 'post' or else the data won't sent back to the database. The good news is that if you type in a cell, and *navigate* to a different record, it will automatically post for you. THE RESULT is that the LAST record  they edit in their session won't be committed unless they call post.
* There may be some fields that you don't want them to be able to edit. To solve this you can either change the SQL query to only bring fields you want them to edit, or set a column in the DBGrid as readonly.

Hope this helps
0
 
mokuleCommented:
And another solution
DBGrid (or DBList)  + a series of DBEdits
In Dbgrid You can display only basic data Name and Last Name for example.
In DBEdits You Can display desired for editing detailed data for a single selected in DBGrid person.
0
 
rfwoolfCommented:
I also want to clarify what I said about using TQueries when the user has chosen the 'database' (table) that they want to see - it can be any dataset, including TTable or TADOTable and you can just set the DBGrid's DataSource to the Datasource that's connected to your dataeset.
A Query was just a good way to do that, but some programmers (like myself) use a lot of TTables instead for certain reasons.
0
 
kretzschmarCommented:
use a TDBCtrlGrid

meikl ;-)
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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