Click here to Skip to main content
15,896,359 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I need to create multiple controls drop box, edit box , checkbox etc in a dialog dynamically at runtime on button click.

The case is that, if user clicks on add button a set of controls should get added in a row into form. if user again clicks add button, again set of controls should get added in new row.

Can anybody suggest any way to achieve this in MFC.


It would look like as below.

|----------------------------------------------------------------| //Form start

Label1 ComboBox1 EditText1 Combobox2 Submit Button

Label2 ComboBox2 EditText2 Combobox3 Submit Button


Label3 ComboBox4 EditText3 Combobox6 Submit Button






|-----------------------------------------------------------------| form end


I know how to create a control dynamically in MFC but for above case I am not sure on approach which will do the job.

Any suggestion will be very much appreciated.

Regards,
Joy

What I have tried:

What I was planning is to write a method in which there will be code to create controls dynamically and I guess I need to track the position of new controls so that controls can be arranged in row dynamically.

This is just a thought have not tried yet. Looking forward to hear from some expert.
Posted
Comments
Richard MacCutchan 5-Jul-16 8:46am    
It is not particularly difficult to do. You calculate the location and size of each control. Create the object and its visible window, setting the dialog as its parent. What is the problem?
Member 14869339 9-Jul-22 0:28am    
How to create a multiple Radio button controls in VC++/MFC one by one on a Dialog.

please help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900