csharp-winform实践开发教程课件(全).ppt

上传人:F****n 文档编号:109331355 上传时间:2019-10-26 格式:PPT 页数:408 大小:18.95MB
返回 下载 相关 举报
csharp-winform实践开发教程课件(全).ppt_第1页
第1页 / 共408页
csharp-winform实践开发教程课件(全).ppt_第2页
第2页 / 共408页
csharp-winform实践开发教程课件(全).ppt_第3页
第3页 / 共408页
csharp-winform实践开发教程课件(全).ppt_第4页
第4页 / 共408页
csharp-winform实践开发教程课件(全).ppt_第5页
第5页 / 共408页
点击查看更多>>
资源描述

《csharp-winform实践开发教程课件(全).ppt》由会员分享,可在线阅读,更多相关《csharp-winform实践开发教程课件(全).ppt(408页珍藏版)》请在金锄头文库上搜索。

1、-基于C#语言,主讲教师:钱 哨a 本课学时:72课时 联系方式:qianshao,Windows程序设计,课程地位,综合基础课程,SQL Server,XML,Ajax Javascript&XML,ASP.NET,Oracle,RSS,Computer Base,HTML&JavaScript,OOPJava,C,Database Base,JSP/Servlet,EJB/WebService,C#,Struts/JSF,Testing/SQA,Linux,WinForms,第一章、Windows编程基础,本章主要内容介绍 1.1 windows和窗体 1.2 Visual Stutio

2、.net IDE简介 1.3 事件处理,CONTENTs,1.1 Windows和窗体,本章学习目标:,理解 Windows 窗体 使用基本控件如标签、文本、按钮、列表框和组合框 掌握窗体的常用属性和方法,GUI界面,1.1 Windows和窗体,各种控件,属性,放置控件的区域,1.1 Windows和窗体,WinForms应用程序可能存在多个窗体,用于获取用户输入的数据和向用户显示数据,System.Windows.Forms,简单而强大 改善了接口和基类 IntelliSense 新的管理数据提供程序 安全 灵活的控件 通晓数据 向导,1.1 Windows和窗体,1.1.2 创建 Win

3、Forms应用程序,“开始”“程序”“Microsoft Visual Studio.NET 2005”“Microsoft Visual Studio.NET 2005”,创建 WinForms应用程序 6-2,设计窗口,1.1.2 创建 WinForms应用程序,using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; namespace SampleProject / / Form1 的摘要说明。 / publ

4、ic class Form1 : System.Windows.Forms.Form / / 必需的设计器变量. / ,提供了大量绘图工具的访问权限,基础核心命名空间,ArrayList、BitArray、Hashtable、Stack、StringCollection 和 StringTable 类,大量窗体和控件,从 System.Windows.Forms.Form 派生,Visual Studio .NET 生成的代码,1.1.2 创建 WinForms应用程序,private System.ComponentModel.Container components = null; pub

5、lic Form1() / / Windows 窗体设计器支持所必需的 / InitializeComponent(); / / TODO:在 InitializeComponent 调用之后 添加任何构造函数代码 / ,构造函数调用 InitializeComponent() 方法,/下面代码见:Form1.Designer.cs文件 private void InitializeComponent() ponents = new System.ComponentModel.Container(); this.Size = new System.Drawing.Size(300,300);

6、this.Text = “Form1“; ,项目的容器,创建 WinForms应用程序,/ / 清理所有正在使用的资源。【下面代码: Form1.Designer.cs 】 / protected override void Dispose( bool disposing ) if( disposing ) if(components != null) components.Dispose(); base.Dispose( disposing ); ,释放系统资源,1.1.2 创建 WinForms应用程序,/下面代码见:program.cs文件 STAThread static void M

7、ain() Application.Run(new Form1(); ,程序的主入口点,1.1.3 WinForms 中的常用控件,可视化界面组件统称为控件,System.Windows.Forms.Control,1.1.3 WinForms 中的常用控件,标签,按钮,组合框,列表框,文本框,标签,1.1.3 WinForms 中的常用控件,标签控件,按钮控件,文本框控件,列表控件,组合框控件,private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) linkLabel1.LinkV

8、isited = true; Form2 newform = new Form2(); newform.Show(); this.Hide(); private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) /label2.Visible = true; label2.Show(); private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) label2.Visible = fal

9、se; label2.Hide(); ,案例:窗口的打开和关闭,文本框,1.1.3 WinForms 中的常用控件,按钮,1.1.3 WinForms 中的常用控件,案例:用户登录设计,private void button2_Click(object sender, EventArgs e) clear(); private void button1_Click(object sender, EventArgs e) if (textBox1.Text = string.Empty | textBox2.Text = string.Empty) MessageBox.Show(“信息禁止为空

10、!“,“登录提示“); clear(); return; if (!textBox1.Text.Equals(“admin“) | !textBox2.Text.Equals(“admin“) MessageBox.Show(“用户名称或密码为空!“, “登录提示“); clear(); return; else MessageBox.Show(“欢迎您登录本系统!“,“消息提示“); clear(); public void clear() textBox1.Clear(); textBox2.Clear(); textBox2.Focus(); ,列表框,1.1.3 WinForms 中的

11、常用控件,使用列表框(1),private void Form1_Load(object sender, EventArgs e) this.listBox1.Items.Add(“软件部“); this.listBox1.Items.Add(“硬件部“); this.listBox1.Items.Add(“财务部“); this.listBox1.Items.Add(“人事部“); ,private void listBox1_SelectedIndexChanged(object sender, EventArgs e) MessageBox.Show(“您选择的部门是:“+listBox

12、1.SelectedItem.ToString()+“,位列第“+listBox1.SelectedIndex.ToString(),“信息提示“); ,使用列表框(2),private void button1_Click(object sender, EventArgs e) listBox1.Items.Clear(); listBox1.Items.Add(“软件部“); listBox1.Items.Add(“硬件部“); listBox1.Items.Add(“财务部“); listBox1.Items.Add(“人事部“); private void button2_Click(

13、object sender, EventArgs e) listBox1.Items.Insert(2,“插入值“); label1.Text = “已经添加“ + listBox1.Items.Count.ToString() + “条记录“; ,组合框,1.1.3 WinForms 中的常用控件,使用组合框,private void Form1_Load(object sender, EventArgs e) boBox1.Items.Add(“财务部“); boBox1.Items.Add(“产品部“); boBox1.Items.Add(“销售部“); boBox1.Items.Add

14、(“生产部“); /默认的选择是“产品部“ boBox1.SelectedIndex = 1; boBox2.Items.Add(“财务部“); boBox2.Items.Add(“产品部“); boBox2.Items.Add(“销售部“); boBox2.Items.Add(“生产部“); /默认的选择是“产品部“ boBox2.SelectedIndex = 1; boBox3.Items.Add(“财务部“); boBox3.Items.Add(“产品部“); boBox3.Items.Add(“销售部“); boBox3.Items.Add(“生产部“); /默认的选择是“产品部“

15、boBox3.SelectedIndex = 1; ,消息框窗口,MessageBox.Show(“消息文本“);,消息框用于显示消息,Abort, Cancel, Ignore, No, None, Ok, Retry 和 Yes,if (MessageBox.Show(“保存文件”,“保存“, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) = DialogResult.Yes) /保存文件所用的代码 /保存后的 MessageBox ,1.1.3 WinForms 中的常用控件,消息框窗口,private void button1_Click(object sender, EventArgs e) MessageBox.Show(“嘿,这是简单提示!“,“信息提示“); private void button2_Click(object sender, EventArgs e) DialogResult result = MessageBox.Show(“嘿,这是问询提示!“,“问询提示“,MessageBoxButtons.YesNo); if (result = DialogResult.Yes) l

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 幼儿/小学教育 > 小学教育

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号