窗體及控件程序設(shè)計_第1頁
窗體及控件程序設(shè)計_第2頁
窗體及控件程序設(shè)計_第3頁
窗體及控件程序設(shè)計_第4頁
窗體及控件程序設(shè)計_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、河南城建學院計算機科學與工程系c#語言windows程序設(shè)計實驗報告實驗名稱:窗體及控件程序設(shè)計成績專業(yè)班級:信息管理與信息系統(tǒng)姓名:趙文普學號:083411151實驗日期:2013 年10 月 日軟件環(huán)境:開發(fā)工具:硬件環(huán)境:硬盤:內(nèi)存:一、實驗?zāi)康?1) 掌握c#窗體創(chuàng)建及其常用控件的選用和編程。(2) 進一步提高編程能力,掌握對c#方法的調(diào)用及其參數(shù)類型的設(shè)置。(3) 練習簡單應(yīng)用程序的規(guī)劃設(shè)計及其程序開發(fā)的方法。二、實驗內(nèi)容(1)設(shè)計一個簡易計算器,包括0,1,2,3,4,5,6,7,8,9,+-*/二十六個按鈕通過一個文木框,顯示輸出的結(jié)果。三、實驗數(shù)據(jù)using system;us

2、ing system. collections generic;using system. componenthodel;using systemdala;using system drawing;using system .text;using system .windows .forms;namespace計算器public partial class form 1 : formpublic form i ()initializecomponento;string stro = strl = "0", result = ",str2=""d

3、ouble pl=0, p2=0;if (strl =hot,) strl = ,tr,;else strl = strl + m1"this.textbox l.text =str2+str 1;private void button2_click(objcct sender, event args c) if (strl =,0") strl = "2"else strl = sirl + "2”;this.textbox l.text = str2 + strl;private void button3_ciick(object send

4、er, eventargs e)if (strl =n0h)strl = h3n;else strl = strl + n3n;this.tcxtbox l.text = str2 + strl;private void button5_click(objcct sender, eventargs c) if (strl =”()“)str 1 = "4”;else strl = sirl + ,f4h;this.textbox l.text = str2 + strl;private void button6_click(object sender, eventargs e)if

5、(strl = h0n) strl =m5h;elsestrl =strl + "5h;this.text box l.text = str2 + strl;private void button 7_click(objcct sender, event args c) if (strl =,0") strl = ,6n;elsesirl =strl + ,6"this.textboxl.lext = str2 + strl;private void button9_click(object sender, eventargs e) if (strl =”0”)s

6、u7“;elsestrl =strl + ,7h;this.tcxtbox l.lcxt = str2 + strl;private void button 10_click(objcct sender, eventargs c) if (strl =,0") strl = ,8n;elsestrl =strl + h8m;this.textboxl.lext = str2 + strl;if (str 1 =hoh)strl = n9h;elsestrl 二 strl +”9”;this.text box l.text = str2 + strl;private void butt

7、on 13_click(objcct sender, eventargs c) if (strl =,o',)strl = "0"elsestrl = strl + "0"this.textboxl.text = str2 + strl;private void button 14_click(object sender, eventargs e) strl =strl + ".n;this.textboxl.text = str2 + strl;this.button 14.enablcd = false;private void b

8、utton4_click(object sender, eventargs e) pl = convert.lodouble(this.textbox 1 .text);stro = this.button4.tcxt;str2 = pl + stro;strl = "0"this.button 15.enabled = true;this.textboxl.text = str2;this.button 14.enabied = true;this-button4.enabled = false;this,button8.enabled = false;this.butt

9、on 12.enabled = false;this.button 16.enabled = false;pl = convert.lbdouble(this.textbox 1 .text); stro = this.button8.lext;str2 = pl + stio;strl = ”0”;this.button 15.enabled = true;this.textboxl.text = str2;this.button 14.enabied = true ; this.button4.enablcd = false; thisbutton&enabled = false;

10、this.button 12.enablcd = false;this.button 16.enabled = false;private void button 12_click(object sender, event args e) pl = convert.t()double(this.textbox 1 .text);stro = this.button 12.1ext;str2 = pl + stro;strl = ”0”;this.button 15.enabled = true;this.textbox l.text = str2;this.button 14.enabled

11、= true ;this.button4.enablcd = false;this.buttons.enablcd = false;this.button 12.enabled = false;this.button 16.enabled = false;private void button 16_click(objcct sender, evcntargs c) pl = con vert.lbdouble(this.textbox 1 .text);stro = this.bullonl6.lext;str2 = pl + stro;strl = ”0”;this.button 15.e

12、nabled = true;this.textboxl.text = str2;this.button 14.enabled = true ;this.button4.enabled = false;this.buttons.enabled = false;this.button 12.enabled = false;this.button 16.enabied = false;private void button 15_click(object sender, eventargs e)p2 = convert.lbdouble(strl);switch (stro) case”+”:res

13、ult = con vcrt.1bstring(p 1 + p2);break;caseresult = convert.lostringcp 1 p2);break;caseresult = convert.lostring(p 1 * p2);break;case ”/”:if (p2 1= 0)resu it = converttbstring(pl / p2);elseresult ="無意義"break;this.tcxtboxl .text = con vert.tostring(p 1) + stio + convert.tostring(p2) + m=m

14、+ result;this.button 1 .enabled =false;this.button2.enabled =false;this.button3.enabled =false;this.button4.enabled = false;this.button5.enabled =false;this.button6.enabled =false;this.button7.enabled =false;this.button8.enablcd = false;th is.button9.en abled =false;this.button 10.enablcd =false;th

15、is.button 11.enabled =false;this.button 12.enablcd = false;this.button 13.enabled =false;this.button 14.en abled =false;this.button 15.enabled =false;this.button 16.enabled = false;private void button 17_cliek(object sender, eventargs e)stro = strl = “o”; result 二"“;str2 = ”;pl = 0; p2 = 0;this

16、.textboxl.lext = "0"this.button 1 .enabled = true; this.button2.enabled = true; this.button3.enabled = true;this.button4.enabled =true;this.button5.enabled=true;this.button6.enab!ed =true; this.button7.enabled=true;this.button8.enabled =true;this.button9.enabled=true;this.button lo.enab le

17、d =tine;this.button 11.enabled=tine;this.button 12.enabled =tme;this.button 13.enabled=true;this.button 14.enabled =true;this.button 15.enab led=false;this.button 16.enabled =true;private void button 18_click(objcct sender, eventargs c) this.close();1)計算器7812457118:0重晉關(guān)閉計算器78*9四、岀現(xiàn)問題及解決方案在編寫程序的過程屮,輸入必須按格式才能進行。如果格式錯誤,程序無法進行,為了解決這一問題采用了控件可見不可見。問題1開始的時候不能直接按等于。問題2小說點,加減乘除的使用不能連續(xù)

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論