แบบฝึกหัด

โปรแกรมที่ 12.1 กล่องข้อความ

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace messagebox
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show.(textBox1.Text, "Output");
        }
    }
}


โปรแกรมที่ 12.2 เครื่องคิดเลข



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void label3_Click(object sender, EventArgs e)
        {
        }
        private void add_Click(object sender, EventArgs e)
        {
            Int32 A, B, X;
            A = Convert.ToInt32(textBox1.Text);
            B = Convert.ToInt32(textBox2.Text);
            X = A + B;
            textBox3.Text = X.ToString();
        }
    }
}

โปรแกรมที่ 12.3  กล่องรูป ภาพ



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace pictrue
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            image.ImageLocation = "D:\\5421414089\\pic1.jpg";
            image.Load();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            image.Image = null;
        }
        private void image_Click(object sender, EventArgs e)
        {
        }
    }
}