I'm refactoring a program containing a lot of forms created dynamically from run-time informations.
To reduce the level of complexity of the system, I thought to write individual code files for each of these forms. Since the forms are many, I'm thinking for a way to automate the process of creation of the forms source code files from data collected at run-time.
E.g. if i have a run-time instance of a form called EditPeople, I want to create the source code of EditPeople.designer.cs, so that then I can edit the form in windows form designer.
Do you know if there is some framework or tool that can simplify this task?
Add TextBox Control and using Property window design your TextBox. Add TreeView Control and using Property window design your TreeView. Bind Data from as DataTable return to DataGridView, ListView, ComboBox and ListBox. Bind Data From XML File as DataTable return to DataGridView, ListView, ComboBox and ListBox.
Windows Forms Designer in Visual Studio provides a rapid development solution for creating Windows Forms-based applications. Windows Forms Designer lets you easily add controls to a form, arrange them, and write code for their events. For more information about Windows Forms, see Windows Forms overview.
The Windows Forms Designer shows the designer surface for the DemoCalculator control. In this view, you can graphically design the appearance of the control by selecting controls and components from Toolbox and placing them on the designer surface.
I just saw this question, for future reference you could try something like this:
public static List<Control> GetAllControls(IList ctrls)
{
List<Control> FormCtrls = new List<Control>();
foreach (Control ctl in ctrls)
{
FormCtrls .Add(ctl);
List<Control> SubCtrls = GetAllControls(ctl.Controls);
FormCtrls .AddRange(SubCtrls);
}
return FormCtrls;
}
You can use this function like this:
List<Control> ReturnedCtrls = GetAllControls(MyForm.Controls);
The when you have a list of all the controls you can do something like this:
foreach(Control ctrl in ReturnedCtrls)
{
// Generate Designer Source using ctrl properties
ctrl.Left
ctrl.Top
// etc...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With