Actually code:

Form Form2 = new Form1(); Form2.Size = new System.Drawing.Size(1000, 300); Form2.BackColor = System.Drawing.Color.Red; Form2.MaximizeBox = false; Form2.MinimizeBox = false; Form2.FormBorderStyle = FormBorderStyle.FixedDialog; Form2.Text = "CryptLocker Moscow"; Label text_for_user = new Label(); text_for_user.ForeColor = System.Drawing.Color.White; text_for_user.Top = 100; text_for_user.AutoSize = false; text_for_user.Text = "HEY, USER!!!"; text_for_user.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; text_for_user.Size = new System.Drawing.Size(50, 50); text_for_user.Font = new System.Drawing.Font("Arial", text_for_user.Font.Size); text_for_user.Dock = System.Windows.Forms.DockStyle.Fill; Form2.Controls.Add(text_for_user); Application.Run(Form2); 

So, the line:

 text_for_user.Size = new System.Drawing.Size(50, 50); 

is meaningless, since it is there, it is not there, whether it costs 50.50 or 500.500 there, while executing the program, the text size does not actually change. What to do?

  • Does the Dock property not override the manual Size value? - Athari
  • Now check. - Semyon Savenko
  • It turned out that the text_for_user.Size property is a conditional size, border, of our Label. How then to increase the size of the text? - Semyon Savenko
  • Why increase it manually if you have AutoSize ? - Athari September

2 answers 2

 Form Form2 = new Form1(); Form2.Size = new System.Drawing.Size(1000, 300); Form2.BackColor = System.Drawing.Color.Red; Form2.MaximizeBox = false; Form2.MinimizeBox = false; Form2.FormBorderStyle = FormBorderStyle.FixedDialog; Form2.Text = "CryptLocker Moscow"; //Написание текста Label text_for_user = new Label(); text_for_user.ForeColor = System.Drawing.Color.White; text_for_user.Top = 150; text_for_user.Left = 500; text_for_user.AutoSize = false; text_for_user.Text = "HEY, USER!!!"; text_for_user.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; text_for_user.Size= new System.Drawing.Size(50, 50); text_for_user.Font = new System.Drawing.Font("Arial", 24, System.Drawing.FontStyle.Bold); //text_for_user.Dock = System.Windows.Forms.DockStyle.Fill; Form2.Controls.Add(text_for_user); Application.Run(Form2); 

    In the properties you need to find Autosize and select False)