mikeyworx

ACTIVITY 7 COMPRO2

Mar 7th, 2023 (edited)
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | Source Code | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3. //  JOHN MICHAEL GONZALES
  4. // ACTIVITY 7 // BSIT CUBAO
  5.  
  6. namespace MyNamespace
  7. {
  8.     public class MyForm : Form
  9.     {
  10.         private TextBox textBox;
  11.         private Button button;
  12.  
  13.         public MyForm()
  14.         {
  15.             // Create the TextBox control and add it to the form
  16.             textBox = new TextBox();
  17.             textBox.Location = new System.Drawing.Point(20, 20);
  18.             textBox.Size = new System.Drawing.Size(200, 20);
  19.             this.Controls.Add(textBox);
  20.  
  21.             // Create the Button control and add it to the form
  22.             button = new Button();
  23.             button.Location = new System.Drawing.Point(20, 50);
  24.             button.Text = "Display Text";
  25.             button.Click += new EventHandler(button_Click);
  26.             this.Controls.Add(button);
  27.         }
  28.  
  29.         private void button_Click(object sender, EventArgs e)
  30.         {
  31.             // Show a message box with the entered text
  32.             MessageBox.Show(textBox.Text);
  33.         }
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment