fork download
  1. //файл с дизайнером, в котором только ввод числа текстбоксов и кнопка
  2.  
  3. namespace WinFormsApp2
  4. {
  5.  
  6. partial class Form1
  7. {
  8. /// <summary>
  9. /// Required designer variable.
  10. /// </summary>
  11. private System.ComponentModel.IContainer components = null;
  12.  
  13. /// <summary>
  14. /// Clean up any resources being used.
  15. /// </summary>
  16. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  17. protected override void Dispose(bool disposing)
  18. {
  19. if (disposing && (components != null))
  20. {
  21. components.Dispose();
  22. }
  23. base.Dispose(disposing);
  24. }
  25.  
  26. #region Windows Form Designer generated code
  27.  
  28. /// <summary>
  29. /// Required method for Designer support - do not modify
  30. /// the contents of this method with the code editor.
  31. /// </summary>
  32. private void InitializeComponent()
  33. {
  34. this.button1 = new System.Windows.Forms.Button();
  35. this.textBoxCreateInput = new System.Windows.Forms.NumericUpDown();
  36. ((System.ComponentModel.ISupportInitialize)(this.textBoxCreateInput)).BeginInit();
  37. this.SuspendLayout();
  38. //
  39. // button1
  40. //
  41. this.button1.Location = new System.Drawing.Point(138, 12);
  42. this.button1.Name = "button1";
  43. this.button1.Size = new System.Drawing.Size(75, 23);
  44. this.button1.TabIndex = 1;
  45. this.button1.Text = "Create";
  46. this.button1.UseVisualStyleBackColor = true;
  47. this.button1.Click += new System.EventHandler(this.button1_Click);
  48. //
  49. // textBoxCreateInput
  50. //
  51. this.textBoxCreateInput.Location = new System.Drawing.Point(12, 12);
  52. this.textBoxCreateInput.Maximum = new decimal(new int[] {
  53. 10,
  54. 0,
  55. 0,
  56. 0});
  57. this.textBoxCreateInput.Name = "textBoxCreateInput";
  58. this.textBoxCreateInput.Size = new System.Drawing.Size(120, 23);
  59. this.textBoxCreateInput.TabIndex = 2;
  60. //
  61. // Form1
  62. //
  63. this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
  64. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  65. this.ClientSize = new System.Drawing.Size(800, 450);
  66. this.Controls.Add(this.textBoxCreateInput);
  67. this.Controls.Add(this.button1);
  68. this.Name = "Form1";
  69. this.Text = "Form1";
  70. ((System.ComponentModel.ISupportInitialize)(this.textBoxCreateInput)).EndInit();
  71. this.ResumeLayout(false);
  72.  
  73. }
  74.  
  75. #endregion
  76. private System.Windows.Forms.Button button1;
  77. private System.Windows.Forms.NumericUpDown textBoxCreateInput;
  78. }
  79. }
  80.  
  81. //------------------------------------------------------------------------------
  82.  
  83. //файл с "логикой", где эта вот залупа происходит
  84. namespace WinFormsApp2
  85. {
  86. using System;
  87. using System.Collections.Generic;
  88. using System.Drawing;
  89. using System.Windows.Forms;
  90.  
  91. public partial class Form1 : Form
  92. {
  93. List<TextBox> _txtBox = new();
  94. public Form1()
  95. {
  96. InitializeComponent();
  97. }
  98.  
  99. private void button1_Click(object sender, EventArgs e)
  100. {
  101. foreach(var x in _txtBox)
  102. {
  103. Controls.Remove(x);
  104. x.Dispose();
  105. }
  106. _txtBox.Clear();
  107.  
  108. int posX = 12;
  109. int posY = 35;
  110. int marg = 25;
  111. for(int i = 0; i < this.textBoxCreateInput.Value; i++)
  112. {
  113. _txtBox.Add(new TextBox
  114. {
  115. Text = $"{i+1}",
  116. Name = $"textBox{i}",
  117. Location = new Point(posX, posY),
  118. Size = new Size(100, 23),
  119. });
  120. posY += marg;
  121. Controls.Add(_txtBox[i]);
  122. }
  123. }
  124. }
  125. }
  126.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(93,36): error CS1525: Unexpected symbol `)', expecting `(' or `type'
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty