簡單寫一個Form的背景變色程式.

程式碼

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 Form1_Load(object sender, EventArgs e)
        {
            BackColor = Color.Blue; //一開始背景就設定為藍色
        }

        private void Form1_Click(object sender, EventArgs e)
        {
            BackColor = Color.Red; //當滑鼠左鍵按下,背景就變為紅色
            Text = "已按下滑鼠左鍵"; //改變Form1的Text顯示
            ControlBox = false;
        }

       
    }
}

程式執行畫面

1. 

2.

 

文章標籤
全站熱搜
創作者介紹
創作者 Alvin 的頭像
Alvin

我的IT學習日誌

Alvin 發表在 痞客邦 留言(0) 人氣(8,289)