C#自學之路18

來源:互聯網
上載者:User

標籤:windows   public   應用程式   false   資訊   

18.windows視窗

  視窗是windows應用程式的基本單元,是一塊螢幕地區,用來向使用者展示資訊和接受使用者的輸入。視窗就好像一個容器,其他介面元素都可以放置在視窗中。

   windows視窗的基本屬性。

   1.視窗的名稱屬性(name)

   2.視窗的標題屬性(text)

   3.視窗的控制功能表屬性:ControlBox屬性,true顯示控制功能表,false不顯示菜單。

                         MaximizeBox屬性,最大化按鈕。

                         MinimizeBox屬性,最小化按鈕。

   4.視窗的外觀屬性:有FormBorderStyle,size,Location,BackColor,BackgroundImage,opacity。


   設定啟動視窗的屬性。

   650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/5F/99/wKioL1UqLSeAg2rMAAJAYakygWA752.jpg" title="%SSLO3B7`W~]MD`_89(]5XI.png " alt="wKioL1UqLSeAg2rMAAJAYakygWA752.jpg" />

修改Application.Run( new +視窗名())就會先啟動指定的視窗了。



單擊Form2上的按鈕,隱藏Form2視窗,顯示Form1視窗。


namespace Calculator

{

    public partial class Form2 : Form

    {

        public Form2()

        {

            InitializeComponent();

        }


        private void button1_Click(object sender, EventArgs e)

        {

            Form1 form1 = new Form1();

            form1.Show();

            this.Hide();

        }

    }

}



視窗的事件。單擊,載入,關閉事件。


       private void Form2_Click(object sender, EventArgs e)

        {

            MessageBox.Show( "單擊了視窗了!!" );

        }


        private void Form2_Load(object sender, EventArgs e)

        {

            this.Width = 1000;

            this.Height = 500;

            this.Text = "welcome!";

        }


        private void Form2_FormClosing(object sender, FormClosingEventArgs e)

        {

            DialogResult dr = MessageBox.Show( "是否關閉視窗?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning );

            if (dr == DialogResult.Yes)

            {

                e.Cancel = false;

            }

            else

            {

                e.Cancel = true;

            }

        }

    }




;650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/5F/9B/wKioL1UqMu-TJnHFAADLAoqPAxg430.jpg" title="R0$%ZHPKNMC4N)O8E3VY64I.jpg" alt="wKioL1UqMu-TJnHFAADLAoqPAxg430.jpg" />

本文出自 “郭俊的部落格” 部落格,轉載請與作者聯絡!

C#自學之路18

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.