版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、 實(shí)驗(yàn)報(bào)告 (2012-2013學(xué)年第二學(xué)期) 課程名稱: .net編程技術(shù) 學(xué)生姓名: 蘭天翔 專業(yè)班級(jí): 10級(jí)計(jì)算機(jī)2班 學(xué) 院: 信電學(xué)院 學(xué) 號(hào): 14514026 學(xué)生成績(jī): 實(shí)驗(yàn)一windows應(yīng)用編程實(shí)驗(yàn)?zāi)康? 掌握windows窗體的基本屬性、事件和方法的使用。2 掌握常用控件的具體使用。實(shí)驗(yàn)內(nèi)容完成字體設(shè)置程序。實(shí)驗(yàn)代碼:using system;using system.collections.generic;using system.componentmodel;using system.data;using system.drawing;using system.te
2、xt;using system.windows.forms;namespace fontset public partial class form1 : form string fontfamily=宋體; float fontsize=10.0f; fontstyle fontstyle=fontstyle.regular; public form1() initializecomponent(); private void setfont() this.richtextbox1.font = new font(fontfamily, fontsize, fontstyle); privat
3、e void rbsongti_checkedchanged(object sender, eventargs e) if (rbsongti.checked) this.fontfamily = 宋體; setfont(); private void rblishu_checkedchanged(object sender, eventargs e) if (rblishu.checked) this.fontfamily = 隸書; setfont(); private void cbbold_checkedchanged(object sender, eventargs e) if (c
4、bbold.checked) this.fontstyle = this.fontstyle| fontstyle.bold; else this.fontstyle -= fontstyle.bold; setfont(); private void cbitalic_checkedchanged(object sender, eventargs e) if (cbitalic.checked) this.fontstyle =this.fontstyle| fontstyle.italic; else this.fontstyle -= fontstyle.italic; setfont(
5、); private void cbunderline_checkedchanged(object sender, eventargs e) if (cbunderline.checked) this.fontstyle = this.fontstyle | fontstyle.underline; else this.fontstyle -= fontstyle.underline; setfont(); private void numericupdown1_valuechanged(object sender, eventargs e) this.fontsize = convert.t
6、osingle(this.numericupdown1.value); setfont(); programusing system;using system.collections.generic;using system.windows.forms;namespace fontset static class program / 應(yīng)用程序的主入口點(diǎn)。 stathread static void main() application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); appl
7、ication.run(new form1(); forml.designernamespace fontset partial class form1 / 必需的設(shè)計(jì)器變量。 private system.componentmodel.icontainer components = null; / 清理所有正在使用的資源。 / 如果應(yīng)釋放托管資源,為 true;否則為 false。 protected override void dispose(bool disposing) if (disposing & (components != null) components.dispose();
8、 base.dispose(disposing); #region windows 窗體設(shè)計(jì)器生成的代碼 / 設(shè)計(jì)器支持所需的方法 - 不要 / 使用代碼編輯器修改此方法的內(nèi)容。 private void initializecomponent() this.groupbox1 = new system.windows.forms.groupbox(); this.groupbox2 = new system.windows.forms.groupbox(); this.groupbox3 = new system.windows.forms.groupbox(); this.rbsongti
9、 = new system.windows.forms.radiobutton(); this.rblishu = new system.windows.forms.radiobutton(); this.numericupdown1 = new system.windows.forms.numericupdown(); this.cbbold = new system.windows.forms.checkbox(); this.cbitalic = new system.windows.forms.checkbox(); this.cbunderline = new system.wind
10、ows.forms.checkbox(); this.richtextbox1 = new system.windows.forms.richtextbox(); this.groupbox1.suspendlayout(); this.groupbox2.suspendlayout(); this.groupbox3.suspendlayout(); (system.componentmodel.isupportinitialize)(this.numericupdown1).begininit(); this.suspendlayout(); / groupbox1 this.groupb
11、ox1.controls.add(this.rblishu); this.groupbox1.controls.add(this.rbsongti); this.groupbox1.location = new system.drawing.point(3, 206); this.groupbox1.name = groupbox1; this.groupbox1.size = new system.drawing.size(208, 199); this.groupbox1.tabindex = 0; this.groupbox1.tabstop = false; this.groupbox
12、1.text = 字體; / groupbox2 this.groupbox2.controls.add(this.numericupdown1); this.groupbox2.location = new system.drawing.point(217, 206); this.groupbox2.name = groupbox2; this.groupbox2.size = new system.drawing.size(201, 199); this.groupbox2.tabindex = 0; this.groupbox2.tabstop = false; this.groupbo
13、x2.text = 大小; / groupbox3 this.groupbox3.controls.add(this.cbunderline); this.groupbox3.controls.add(this.cbitalic); this.groupbox3.controls.add(this.cbbold); this.groupbox3.location = new system.drawing.point(424, 206); this.groupbox3.name = groupbox3; this.groupbox3.size = new system.drawing.size(
14、216, 199); this.groupbox3.tabindex = 0; this.groupbox3.tabstop = false; this.groupbox3.text = 風(fēng)格; / rbsongti this.rbsongti.autosize = true; this.rbsongti.location = new system.drawing.point(27, 41); this.rbsongti.name = rbsongti; this.rbsongti.size = new system.drawing.size(47, 16); this.rbsongti.ta
15、bindex = 0; this.rbsongti.tabstop = true; this.rbsongti.text = 宋體; this.rbsongti.usevisualstylebackcolor = true; this.rbsongti.checkedchanged += new system.eventhandler(this.rbsongti_checkedchanged); / rblishu this.rblishu.autosize = true; this.rblishu.location = new system.drawing.point(27, 81); th
16、is.rblishu.name = rblishu; this.rblishu.size = new system.drawing.size(47, 16); this.rblishu.tabindex = 1; this.rblishu.tabstop = true; this.rblishu.text = 隸書; this.rblishu.usevisualstylebackcolor = true; this.rblishu.checkedchanged += new system.eventhandler(this.rblishu_checkedchanged); / numericu
17、pdown1 this.numericupdown1.location = new system.drawing.point(36, 52); this.numericupdown1.name = numericupdown1; this.numericupdown1.size = new system.drawing.size(120, 21); this.numericupdown1.tabindex = 2; this.numericupdown1.value = new decimal(new int 10, 0,0, 0); this.numericupdown1.valuechan
18、ged += new system.eventhandler(this.numericupdown1_valuechanged); / cbbold this.cbbold.autosize = true; this.cbbold.location = new system.drawing.point(50, 41); this.cbbold.name = cbbold; this.cbbold.size = new system.drawing.size(48, 16); this.cbbold.tabindex = 3; this.cbbold.text = 粗體; this.cbbold
19、.usevisualstylebackcolor = true; this.cbbold.checkedchanged += new system.eventhandler(this.cbbold_checkedchanged); / cbitalic this.cbitalic.autosize = true; this.cbitalic.location = new system.drawing.point(50, 81); this.cbitalic.name = cbitalic; this.cbitalic.size = new system.drawing.size(48, 16)
20、; this.cbitalic.tabindex = 4; this.cbitalic.text = 斜體; this.cbitalic.usevisualstylebackcolor = true; this.cbitalic.checkedchanged += new system.eventhandler(this.cbitalic_checkedchanged); / cbunderline this.cbunderline.autosize = true; this.cbunderline.location = new system.drawing.point(50, 121); t
21、his.cbunderline.name = cbunderline; this.cbunderline.size = new system.drawing.size(60, 16); this.cbunderline.tabindex = 5; this.cbunderline.text = 下劃線; this.cbunderline.usevisualstylebackcolor = true; this.cbunderline.checkedchanged += new system.eventhandler(this.cbunderline_checkedchanged); / ric
22、htextbox1 this.richtextbox1.location = new system.drawing.point(0, 0); this.richtextbox1.name = richtextbox1; this.richtextbox1.size = new system.drawing.size(640, 200); this.richtextbox1.tabindex = 1; this.richtextbox1.text = ; / form1 this.autoscaledimensions = new system.drawing.sizef(6f, 12f); t
23、his.autoscalemode = system.windows.forms.autoscalemode.font; this.clientsize = new system.drawing.size(641, 404); this.controls.add(this.richtextbox1); this.controls.add(this.groupbox3); this.controls.add(this.groupbox2); this.controls.add(this.groupbox1); this.name = form1; this.text = form1; this.
24、groupbox1.resumelayout(false); this.groupbox1.performlayout(); this.groupbox2.resumelayout(false); this.groupbox3.resumelayout(false); this.groupbox3.performlayout(); (system.componentmodel.isupportinitialize)(this.numericupdown1).endinit(); this.resumelayout(false); #endregion private system.window
25、s.forms.groupbox groupbox1; private system.windows.forms.groupbox groupbox2; private system.windows.forms.groupbox groupbox3; private system.windows.forms.radiobutton rblishu; private system.windows.forms.radiobutton rbsongti; private system.windows.forms.numericupdown numericupdown1; private system
26、.windows.forms.checkbox cbunderline; private system.windows.forms.checkbox cbitalic; private system.windows.forms.checkbox cbbold; private system.windows.forms.richtextbox richtextbox1; 實(shí)驗(yàn)二 圖形圖像編程實(shí)驗(yàn)?zāi)康? 掌握graphics類。2 掌握基本的繪圖方法。3 掌握?qǐng)D像的顯示和處理方法。實(shí)驗(yàn)內(nèi)容完成畫板應(yīng)用。在窗體的空白處繪圖,并將圖片保存起來(lái)。實(shí)驗(yàn)代碼:using system;using syste
27、m.collections.generic;using system.componentmodel;using system.data;using system.drawing;using system.text;using system.windows.forms;namespace windraw public partial class form1 : form graphics dc; bitmap bmp = new bitmap(800, 800); point p0; point p1; bool ispress = false; public form1() initializ
28、ecomponent(); dc = graphics.fromimage(bmp); private void button1_click(object sender, eventargs e) this.savefiledialog1.filter = bmp圖片|*.bmp; if (this.savefiledialog1.showdialog() = dialogresult.ok) this.bmp.save(this.savefiledialog1.filename); private void drawimage() if (ispress) dc.drawline(pens.
29、red, p0, p1); this.picturebox1.image = bmp; private void picturebox1_mousedown(object sender, mouseeventargs e) p0 = e.location; ispress = true; private void picturebox1_mousemove(object sender, mouseeventargs e) p1 = e.location; drawimage(); p0 = p1; private void picturebox1_mouseup(object sender,
30、mouseeventargs e) p1 = e.location; drawimage(); ispress = false; program:using system;using system.collections.generic;using system.windows.forms;namespace windraw static class program / 應(yīng)用程序的主入口點(diǎn)。 stathread static void main() application.enablevisualstyles(); application.setcompatibletextrenderingd
31、efault(false); application.run(new form1(); forml .designernamespace windraw partial class form1 / 必需的設(shè)計(jì)器變量。 private system.componentmodel.icontainer components = null; / 清理所有正在使用的資源。 / 如果應(yīng)釋放托管資源,為 true;否則為 false。 protected override void dispose(bool disposing) if (disposing & (components != null) c
32、omponents.dispose(); base.dispose(disposing); #region windows 窗體設(shè)計(jì)器生成的代碼 / 設(shè)計(jì)器支持所需的方法 - 不要 / 使用代碼編輯器修改此方法的內(nèi)容。 private void initializecomponent() this.picturebox1 = new system.windows.forms.picturebox(); this.button1 = new system.windows.forms.button(); this.savefiledialog1 = new system.windows.forms
33、.savefiledialog(); (system.componentmodel.isupportinitialize)(this.picturebox1).begininit(); this.suspendlayout(); / picturebox1 this.picturebox1.backcolor = system.drawing.color.white; this.picturebox1.location = new system.drawing.point(0, 0); this.picturebox1.name = picturebox1; this.picturebox1.
34、size = new system.drawing.size(517, 361); this.picturebox1.tabindex = 0; this.picturebox1.tabstop = false; this.picturebox1.mousedown += new system.windows.forms.mouseeventhandler(this.picturebox1_mousedown); this.picturebox1.mousemove += new system.windows.forms.mouseeventhandler(this.picturebox1_m
35、ousemove); this.picturebox1.mouseup += new system.windows.forms.mouseeventhandler(this.picturebox1_mouseup); / button1 this.button1.location = new system.drawing.point(0, 367); this.button1.name = button1; this.button1.size = new system.drawing.size(75, 23); this.button1.tabindex = 1; this.button1.t
36、ext = 保存; this.button1.usevisualstylebackcolor = true; this.button1.click += new system.eventhandler(this.button1_click); / form1 this.autoscaledimensions = new system.drawing.sizef(6f, 12f); this.autoscalemode = system.windows.forms.autoscalemode.font; this.clientsize = new system.drawing.size(517,
37、 392); this.controls.add(this.button1); this.controls.add(this.picturebox1); this.name = form1; this.text = form1; (system.componentmodel.isupportinitialize)(this.picturebox1).endinit(); this.resumelayout(false); #endregion private system.windows.forms.picturebox picturebox1; private system.windows.
38、forms.button button1; private system.windows.forms.savefiledialog savefiledialog1; 實(shí)驗(yàn)三 數(shù)據(jù)庫(kù)編程實(shí)驗(yàn)?zāi)康? 理解ado.net對(duì)象模型。2 熟悉常用數(shù)據(jù)邦定控件的使用方法。實(shí)驗(yàn)內(nèi)容完成簡(jiǎn)單學(xué)生信息系統(tǒng),能夠查詢學(xué)生信息,增、刪、改學(xué)生信息。實(shí)驗(yàn)代碼:formlusing system;using system.collections.generic;using system.componentmodel;using system.data;using system.drawing;using system.
39、text;using system.windows.forms;using system.data.sqlclient;namespace winstudb public partial class form1 : form sqlhelper helper = new sqlhelper(); public form1() initializecomponent(); private void form1_load(object sender, eventargs e) dataset ds; /ds=helper.selectsqlreturndataset(select * from s
40、tudent); /string cmdtext = select * from student where ssex=ssex and sno=sno; /string ssex; /ssex = 男; /string sno; /sno = 1; /sqlparameter pars = new sqlparameter / / new sqlparameter(ssex,ssex), / new sqlparameter(sno,sno) /; /ds = helper.selectsqlreturndataset(cmdtext, pars, commandtype.text); ds
41、 = helper.selectsqlreturndataset(select * from student, null, commandtype.text); this.datagridview1.datasource = ds.tables0; private void datagridview1_cellclick(object sender, datagridviewcelleventargs e) /this.datagridview1.currentrow.selected = true; binddata(); private void btadd_click(object se
42、nder, eventargs e) string sql = insert into student(sno,sname,ssex) values ( sno, sname, ssex); sqlparameter pars= new sqlparameter new sqlparameter(sno,tbsno.text), new sqlparameter(sname,tbsname.text), new sqlparameter(ssex,tbssex.text) ; int count = helper.executesqlreturnint(sql, pars, commandtype.text); if (count 0) this.datagridview1.datasource = helper.selectsqlreturndataset(select * from student).tables0; messagebox.show(添加成功); private void datagridview1_celldoubleclick(object sender, datagrid
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 遼源職業(yè)技術(shù)學(xué)院《建筑工業(yè)化與裝配式結(jié)構(gòu)》2023-2024學(xué)年第一學(xué)期期末試卷
- 廊坊職業(yè)技術(shù)學(xué)院《計(jì)算機(jī)通信網(wǎng)絡(luò)》2023-2024學(xué)年第一學(xué)期期末試卷
- 江西水利職業(yè)學(xué)院《汽車輕量化技術(shù)》2023-2024學(xué)年第一學(xué)期期末試卷
- 建東職業(yè)技術(shù)學(xué)院《法語(yǔ)二外》2023-2024學(xué)年第一學(xué)期期末試卷
- 湖州學(xué)院《項(xiàng)目設(shè)計(jì)》2023-2024學(xué)年第一學(xué)期期末試卷
- 湖南國(guó)防工業(yè)職業(yè)技術(shù)學(xué)院《混凝土結(jié)構(gòu)基本原理A》2023-2024學(xué)年第一學(xué)期期末試卷
- 呼倫貝爾職業(yè)技術(shù)學(xué)院《數(shù)量分析方法》2023-2024學(xué)年第一學(xué)期期末試卷
- 自貢職業(yè)技術(shù)學(xué)院《仿真實(shí)訓(xùn)》2023-2024學(xué)年第一學(xué)期期末試卷
- 周口理工職業(yè)學(xué)院《生物化工設(shè)備》2023-2024學(xué)年第一學(xué)期期末試卷
- 重慶科創(chuàng)職業(yè)學(xué)院《網(wǎng)絡(luò)課程綜合》2023-2024學(xué)年第一學(xué)期期末試卷
- 2024年08月云南省農(nóng)村信用社秋季校園招考750名工作人員筆試歷年參考題庫(kù)附帶答案詳解
- 防詐騙安全知識(shí)培訓(xùn)課件
- 心肺復(fù)蘇課件2024
- 2024年股東股權(quán)繼承轉(zhuǎn)讓協(xié)議3篇
- 2024-2025學(xué)年江蘇省南京市高二上冊(cè)期末數(shù)學(xué)檢測(cè)試卷(含解析)
- 四川省名校2025屆高三第二次模擬考試英語(yǔ)試卷含解析
- 考研有機(jī)化學(xué)重點(diǎn)
- 全國(guó)身份證前六位、區(qū)號(hào)、郵編-編碼大全
- 《GPU體系結(jié)構(gòu)》課件2
- 三年級(jí)語(yǔ)文上冊(cè) 期末古詩(shī)詞專項(xiàng)訓(xùn)練(二)(含答案)(部編版)
- 《護(hù)士條例》課件
評(píng)論
0/150
提交評(píng)論