初始Windows程式

來源:互聯網
上載者:User

標籤:解決方案   判斷   控制項   閃電   dial   position   word   資訊   ext   

一.表單的屬性

1.背景顏色:BackColor
2.背景圖片:BackGroundImage
3.設定表單標題:Text
4.表單表徵圖:icon
5.設定表單更改大小:Formboderstyle
6.設定表單顯示位置:StartPosition
7.設定背景映像平鋪方式:BackGroundImageLayout
8.設定下拉框不可更改:DropDownStyle
9.設定密碼框顯示文字:PasswordChar

二.表單控制項

1.標籤:Lable 首碼:lbl
2.文字框:TextBox 首碼:txt
3.組合框:ComboBox 首碼:cbo
4.按鈕:Button首碼:btn

三.為控制項註冊事件


點擊控制項,點擊閃電,選擇要註冊的事件雙擊

如果想要刪除事件代碼,那就需要在刪除之後在.Designer.cs檔案中刪除錯誤碼

四.訊息提示框

MessageBox.Show("提示資訊");
MessageBox.Show("提示資訊","提示標題");
MessageBox.Show("提示資訊","提示標題",MessageBoxButtons.YesNo(確定取消按鈕));
MessageBox.Show("提示資訊","提示標題",MessageBoxButtons.YesNo(確定取消按鈕),MessageBoxIcon.Stop(提示映像));

1.接收提示框的傳回值

//友好提示,訊息框
DialogResult result=MessageBox.Show("確定取消登入嗎?","呵呵!",MessageBoxButtons.YesNo,MessageBoxIcon.Error);
//判斷訊息框點擊按鈕的值
if (result == DialogResult.Yes) {
//關閉表單
this.Close();
}

五.擷取文字框輸入的值

1. this.文字框名稱.Text
2. 獲得文字框焦點

this.文字框名稱.Fouce();
六.展示表單以及傳值

1.展示表單

表單名稱 執行個體名=new 表單名稱();
執行個體名.Show();

FrmMain main=new FrmMain();
main.Show();

2.表單傳值
將一個表單的值傳入到另外一個表單當中去

解決方案一:在建立表單的執行個體時將值傳入
FrmMain main=new FrmMain(傳入的值);
public FrmMain(形參)
{

InitializeComponent();
this.Text=形參;
}

解決方案二:註冊一個Load()事件,在表單Show()之前會自動調用Load()

FrmMain main = new FrmMain();
main.name = "歡迎您:" + this.txtName.Text;
main.Show();

 

public string name;
private void FrmMain_Load(object sender, EventArgs e)
{
this.Text = name;
}

 

初始Windows程式

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.