Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Form Controls

Tags:

c#

.net

winforms

Using C# 2.0 what is the best way to implement dynamic form controls?

I need to provide a set of controls per data object, so should i just do it manually and lay them out while increment the top value or is there a better way?

like image 348
Sam Avatar asked Sep 04 '08 11:09

Sam


People also ask

What is meant by dynamic form?

Dynamic forms are composite forms that allow you to present varying amounts of data to users. These forms change their layout according to the data they receive from the prefilling services at the time of rendering, so each separate request for form generation produces a form with a different length or content.

What are Salesforce dynamic forms?

What are Salesforce Dynamic Forms? The premise of Dynamic Forms is to create user centric, intuitive page layouts that display the right information at the right time. Over time, the page layout, or “Details” section in Lightning pages, can become congested with fields.

What is dynamic forms in Angular?

A dynamic form requires an object model that can describe all scenarios needed by the form functionality. The example hero-application form is a set of questions —that is, each control in the form must ask a question and accept an answer. The data model for this type of form must represent a question.

What is difference between dynamic and page layout?

Unlike the traditional page layout where you can only add a field once, you can add a field multiple times using Dynamic Forms. The reason for this is because you may create multiple Field Sections that display fields based on different criteria or for different record types or users.


3 Answers

You can use panels with automatic layout such as FlowLayoutPanel and TableLayoutPanel.

Unfortunately there are only 2 panels with automatic layout out of box but you can create custom layout panel.

I would recommend you to read following articles:

How to: Create a Resizable Windows Form for Data Entry

Walkthrough: Creating a Resizable Windows Form for Data Entry

Another option would be using of WPF (Windows Presentation Presentation).
WPF is a perfect match for your task.
WPF controls can be hosted in WinForms apps so you don't have to switch to it completely.

like image 59
aku Avatar answered Oct 23 '22 04:10

aku


@Sam I know this question was about Windows Forms, but you should definitely start looking at WPF. This sort of scenario is really easy in WPF with DataTemplates and TemplateSelectors.

like image 31
Matt Hamilton Avatar answered Oct 23 '22 04:10

Matt Hamilton


What do you mean by “dynamic”? A new, fixed set of controls for each data row in the data set? Then use a UserControl that contains your controls.

Or do you mean that, depending on your data layout, you want to provide the user with a customized set of controls, say, one TextBox for each column?

like image 1
Konrad Rudolph Avatar answered Oct 23 '22 04:10

Konrad Rudolph