




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、 實驗報告 (2012-2013學年第二學期) 課程名稱: .net編程技術 學生姓名: 蘭天翔 專業(yè)班級: 10級計算機2班 學 院: 信電學院 學 號: 14514026 學生成績: 實驗一windows應用編程實驗目的1 掌握windows窗體的基本屬性、事件和方法的使用。2 掌握常用控件的具體使用。實驗內容完成字體設置程序。實驗代碼: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 / 應用程序的主入口點。 stathread static void main() application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); appl
7、ication.run(new form1(); forml.designernamespace fontset partial class form1 / 必需的設計器變量。 private system.componentmodel.icontainer components = null; / 清理所有正在使用的資源。 / 如果應釋放托管資源,為 true;否則為 false。 protected override void dispose(bool disposing) if (disposing & (components != null) components.dispose();
8、 base.dispose(disposing); #region windows 窗體設計器生成的代碼 / 設計器支持所需的方法 - 不要 / 使用代碼編輯器修改此方法的內容。 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 = 風格; / 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; 實驗二 圖形圖像編程實驗目的1 掌握graphics類。2 掌握基本的繪圖方法。3 掌握圖像的顯示和處理方法。實驗內容完成畫板應用。在窗體的空白處繪圖,并將圖片保存起來。實驗代碼: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 / 應用程序的主入口點。 stathread static void main() application.enablevisualstyles(); application.setcompatibletextrenderingd
31、efault(false); application.run(new form1(); forml .designernamespace windraw partial class form1 / 必需的設計器變量。 private system.componentmodel.icontainer components = null; / 清理所有正在使用的資源。 / 如果應釋放托管資源,為 true;否則為 false。 protected override void dispose(bool disposing) if (disposing & (components != null) c
32、omponents.dispose(); base.dispose(disposing); #region windows 窗體設計器生成的代碼 / 設計器支持所需的方法 - 不要 / 使用代碼編輯器修改此方法的內容。 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ù)據(jù)庫編程實驗目的1 理解ado.net對象模型。2 熟悉常用數(shù)據(jù)邦定控件的使用方法。實驗內容完成簡單學生信息系統(tǒng),能夠查詢學生信息,增、刪、改學生信息。實驗代碼: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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 醫(yī)療儀器使用和維護手冊
- 醫(yī)藥研發(fā)項目管理方案
- 安全文明施工措施費怎么算
- 懷化沅陵垃圾焚燒發(fā)電項目
- 安全技術措施施工方案
- 健康產(chǎn)業(yè)在線健康咨詢服務平臺開發(fā)與運營策略
- 科技創(chuàng)新經(jīng)濟發(fā)展形勢
- 醫(yī)療健康大數(shù)據(jù)平臺數(shù)據(jù)共享手冊
- 登高安全作業(yè)施工方案
- 醫(yī)療機構疾病預防控制預案
- 噴漆工崗位能力培訓試題含答案
- 江南大學《互換性與技術測量》2021-2022學年第一學期期末試卷
- ECharts數(shù)據(jù)可視化課件 第5章 儀表盤、漏斗圖和折線樹圖
- 特殊作業(yè)安全管理監(jiān)護人專項培訓課件
- 農(nóng)行競聘高級專員述職報告范本
- 2024屆全國新高考英語復習-讀后續(xù)寫微寫作
- 陜西省咸陽市實驗中學高一下學期第一次月考物理試題(原卷版)
- 上下級權責關系與溝通管理制度
- 眼部疼痛的病理生理機制
- 部編版道德與法治二年級下冊第二單元備課
- 保證金合同范文(2024版)
評論
0/150
提交評論