国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

C#編程三步走之三

2024-07-21 02:17:40
字體:
來源:轉載
供稿:網友


第三步 增加響應用戶事件代碼
還有最后一步就可以大功告成了,就是增加一個方法來捕捉按鈕點擊
事件。這里就是指從攝氏到華氏的按鈕點擊代碼:
private void bnctof_click(object sender,
eventargs e) {
double dtempcel = 0;
double dtempfah = 0;
try { dtempcel = ttempcel.text.todouble(); }
catch(exception) {
ttempcel.clear();
ttempfah.clear();
return;
}
dtempfah = 1.8*dtempcel+32;
ttempfah.text = dtempfah.tostring();
ttempfah.focus();
ttempfah.selectionstart = 0;
ttempfah.selectionlength = 0;
ttempcel.focus();
ttempcel.selectionstart = 0;
ttempcel.selectionlength = 0;
}

以下是fahrenheit按鈕的代碼,它將完成同樣的任務,只不過是相反
的處理:
private void bnftoc_click(object sender,
eventargs e) {
double dtempcel = 0;
double dtempfah = 0;
try { dtempfah = ttempfah.text.todouble(); }
catch(exception) {
ttempcel.clear();
ttempfah.clear();
return;
}
dtempcel = (dtempfah-32)/1.8;
ttempcel.text = dtempcel.tostring();
ttempcel.focus();
ttempcel.selectionstart = 0;
ttempcel.selectionlength = 0;
ttempfah.focus();
ttempfah.selectionstart = 0;
ttempfah.selectionlength = 0;
}
接著,我們需要將適當的點擊事件捕捉方法與按鈕的 click事件聯系
起來。要完成這一步,我們將以下兩行放在類的構造器中:
bnctof.click += new eventhandler
(this.bnctof_click);
bnftoc.click += new eventhandler
(this.bnftoc_click);

上一篇:C#簡明教程一

下一篇:C#編程三步走之二

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 定边县| 仁化县| 阿克苏市| 藁城市| 铁岭县| 桃江县| 洛阳市| 永修县| 怀来县| 仁寿县| 永寿县| 满城县| 宝兴县| 台东市| 贺兰县| 万山特区| 韶山市| 湘阴县| 东乡族自治县| 大宁县| 龙里县| 抚顺市| 青岛市| 黄平县| 永善县| 易门县| 大新县| 仁布县| 镇远县| 正安县| 陇南市| 子洲县| 邵阳县| 南昌市| 甘肃省| 大宁县| 牙克石市| 漳平市| 武冈市| 仙桃市| 清镇市|