I have a table in DB with information about some goods. Goods may be fillable, so we can add text to it. So I want to dynamically generate a list of checkboxes related to info in table and even some checkboxes must be with TEdit component to make a possibility to add text to this item. So how can I do it? What component should I use? I figure out that TTreeView is almost enough, but it doesn’t allow to “draw” TEdit near checkboxes. I’m using Delphi 2010. Thanks in advance! Hope for your help!
Share
If I read your question correctly, you would like to create some controls on a form based on the contents of table. In the following example I have assumed you want to do this based on the contents of the current record in a TDBGrid, so you’ll have to adapt as needed.
The example assumes a form with a TDBGrid and a TPanel (Panel1) that will hold the controls created at run time.
The TDBGrid will be connected to a TDataSource component and that will be connected to some TDataSet descendant for the table/query with the information. The TDataSource has a OnDataChanged event. This event gets triggered when the data in a field changes or when the current record in the dataset changes. So you can use that to change the controls as the current record changes.
Please note that if you do not have any other checkboxes or edits on the form, you will have to include the proper vcl units yourself. The easiest way to do that is to drop them on the form, save the form and then delete the controls again.