Accordion based forms with dynamic controls

Add-in Express™ Support Service
That's what is more important than anything else

Accordion based forms with dynamic controls
 
IT Support


Guest


Hello,

1) I want to create an outlook form with accordions whereby, by clicking on specifics headers I want panels to expand and accommodate certain controls.

2)The number of textboxes, dropdowns and labels under every header would be dynamic and so would the text of the labels and contents of the dropdowns. The text of the accordion header would also be dynamic ie. based on values of fields returned from another api depending on the combinations of user's inputs in the form.

What is the best way to go about this?
Any little direction to proceed in to achieve this would be appreciated.

Thank you
Posted 23 May, 2017 08:59:00 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello,

If you want to competely redraw an Add-in Express form, check section https://www.add-in-express.com/creating-addins-blog/2016/05/31/customize-appearance-excel-task-panes-outlook-regions/. Otherwise, you can create a UserControl containing all the controls you need and put the userControl onto the form.

As to creating the controls dynamically, you can start with creating a windows Forms application, creating a form (userControl), populating it with controls at the design time, and studying the Initializecomponent() method to find the code involved in the process.


Andrei Smolin
Add-in Express Team Leader
Posted 23 May, 2017 09:44:27 Top
IT Support


Guest


Hello,

Andrei Smolin writes:
Otherwise, you can create a UserControl containing all the controls you need and put the userControl onto the form.

As to creating the controls dynamically, you can start with creating a windows Forms application, creating a form (userControl), populating it with controls at the design time


I have already done this. I created so many some 5 user controls for 5 situations and it works fine. But, I could have hundreds of different cases for which I needed to use a dynamic approach whereby, say I get all the textboxes and other fields in a json string from another api, I wanted to program to create the form dynamically

Thank you
Posted 23 May, 2017 10:03:52 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
I see. Alas, this isn't a task that we could help you with.


Andrei Smolin
Add-in Express Team Leader
Posted 24 May, 2017 06:02:31 Top
Marcus from London


Guest


Hi 'IT Support',

You can certainly add controls dynamically (at run time) to a Windows Form.
There's plenty of tutorials available online, like this:
https://support.microsoft.com/en-us/help/319266/how-to-programmatically-add-controls-to-windows-forms-at-run-time-by-using-visual-c

Books like "Pro .NET 2.0 Windows Forms and Custom Controls in C#" also cover this topic well.

Alternatively, depending on the structure of the data you need to present, would a grid control be suitable?

Finally, whilst a more expensive alternative (but hey, time is money!), you may want to consider a library of 3rd party controls.
Pieter from Add-In Express has a good comparison of several libraries suitable for Add-In Express development here:

https://www.add-in-express.com/creating-addins-blog/2012/04/02/windows-forms-controls-office/


Cheers - Marcus
Posted 24 May, 2017 09:45:04 Top