Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void GenerateControls(string formType)
- {
- string[] formParameters = engine.GetFormParameters(formType);
- if (formParameters == null) return;
- SplitterPanel panel = splitContainer.Panel1;
- panel.Controls.Clear();
- List<Pair<Label, TextBox>> controlPairs = new List<Pair<Label, TextBox>>();
- int tabIndex = 0;
- Point labelPoint = panel.Location + new Size(20, 20);
- Size initialOffset = new Size(0, 30);
- Size horizontalOffset = new Size(40, 0);
- Size tBoxSize = new Size(40,20);
- foreach (string parameter in formParameters)
- {
- Label label = new Label
- {
- Text = parameter,
- Tag = "Parameter Label",
- Name = $"lbl{parameter}",
- Location = (labelPoint += initialOffset)
- };
- TextBox textBox = new TextBox
- {
- AcceptsTab = true,
- TabIndex = tabIndex++,
- Text = "",
- Tag = parameter,
- Name = $"txt{parameter}",
- MaximumSize = tBoxSize,
- MinimumSize = tBoxSize,
- Size = tBoxSize,
- Location = labelPoint + horizontalOffset
- };
- controlPairs.Add(new Pair<Label, TextBox>(label, textBox));
- }
- foreach (Pair<Label, TextBox> pair in controlPairs)
- {
- panel.Controls.Add(pair.First);
- panel.Controls.Add(pair.Second);
- }
- }
- private void GenerateControls(string formType)
- {
- string[] formParameters = engine.GetFormParameters(formType);
- if (formParameters == null) return;
- SplitterPanel panel = splitContainer.Panel1;
- panel.Controls.Clear();
- int tabIndex = 0;
- Point labelPoint = panel.Location + new Size(20, 20);
- Size verticalOffset = new Size(0, 30);
- Size tBoxSize = new Size(200,20);
- int maxLabelLength = 0;
- foreach (string parameter in formParameters)
- {
- Label label = new Label
- {
- Text = parameter,
- Tag = "Parameter Label",
- Name = $"lbl{parameter}",
- Location = (labelPoint += verticalOffset),
- AutoSize = true
- };
- panel.Controls.Add(label);
- if (label.Size.Width > maxLabelLength)
- {
- maxLabelLength = label.Size.Width;
- }
- }
- Size horizontalOffset = new Size(maxLabelLength + 30, 0);
- labelPoint = panel.Location + new Size(20, 20) + horizontalOffset;
- foreach (string parameter in formParameters)
- {
- TextBox textBox = new TextBox
- {
- AcceptsTab = true,
- TabIndex = tabIndex++,
- Text = "",
- Tag = parameter,
- Name = $"txt{parameter}",
- MaximumSize = tBoxSize,
- MinimumSize = tBoxSize,
- Size = tBoxSize,
- Location = labelPoint += verticalOffset
- };
- panel.Controls.Add(textBox);
- }
- }
Add Comment
Please, Sign In to add comment