A
A
Arkadiysm2019-06-26 22:50:17
C++ / C#
Arkadiysm, 2019-06-26 22:50:17

How to display text in a form in windows forms?

The bottom line is that there is a piece of code that displays the result of the work in the console, but it is necessary that it displays windows forms on the screen, a few hours of googling did not help

int a = 1;
int b = a;
int c;
            
for (int i = 0; i < 8; i++) {
  c = a + b;
  a = b;
  b = c;
  Console.WriteLine(c);
  System.Threading.Thread.Sleep(1000);
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew Nodermann, 2019-06-26
@Lucian

https://www.c-sharpcorner.com/article/working-with...

B
baimkin, 2019-06-27
@baimkin

int a = 1;
int b = a;
int c;

//Создаем форму
System.Windows.Forms.Form form = new System.Windows.Forms.Form();
//Задаем размер
form.Size = new System.Drawing.Size(640, 480);
//Создаем текстовое поле
System.Windows.Forms.RichTextBox richTextBox = new System.Windows.Forms.RichTextBox();
//Задаем размер поля на всю форму
richTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
//Добавляем поле на форму
form.Controls.Add(richTextBox);
            
for (int i = 0; i < 8; i++) {
  c = a + b;
  a = b;
  b = c;
  //Записываем значение текста с новой строки
  richTextBox.Text = richTextBox.Text + c + System.Environment.NewLine;
  System.Threading.Thread.Sleep(1000);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question