今天由于是周六,所以就没讲课啦,于是我就仔细看啦几道还没掌握的题,然后总结啦一下。

一.三级联动

像这个三级联动吧,感觉在做网站时间肯定会用到啦,但是那时间肯定不会是这样子做的啦,不可能把所有的省市区区什么的全部给添加到一个数组里面排列出来,所以学习这个从基础学起啦,先培养下思想,列举出来几个省市区然后列举出来,下面就简单列举下河南,河北和西藏这三个省的市和区,如下所示:

public partial class Form1 : Form
{
string[] pri = { "请选择省份","河南", "河北", "西藏" }; string[] henancity = { "请选择城市", "郑州", "洛阳", "新乡" };
string[] hebeicity = { "请选择城市", "北京", "石家庄", "张家口", "邯郸" };
string[] xizangcity = { "请选择城市", "拉萨" }; string[] zhengzhouarea = { "请选择区域", "金水区", "中原区", "二七区", "经开区", "管城区" };
string[] luoyangarea = { "请选择区域", "洛龙区", "吉利区", "老城区", "西工区", "涧西区" };
string[] xinxiangarea = { "请选择区域", "红旗区", "牧野区", "卫滨区", "凤泉区" }; string[] beijingarea = { "请选择区域", "海淀区", "朝阳区", "东城区", "西城区", "丰台区" };
string[] shijiazhuangarea = { "请选择区域", "请选择区域", "桥东区", "桥西区", "裕华区", "新华区", "长安区" };
string[] zhangjiakouarea = { "请选择区域", "高新区", "塞北区", "察北区", "桥东区", "桥西区" };
string[] handanarea = { "请选择区域", "丛台区", "邯山区", "复兴区", "峰峰矿区" }; string[] lasaarea = { "请选择区域", "日喀则地区", "昌都地区", "林芝地区", "山南地区", "那曲地区", "阿里地区" }; public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.conpri.Items.AddRange(pri);
this.conpri.SelectedIndex = ;
}
private void conpri_SelectedIndexChanged(object sender, EventArgs e)
{
string value =this.conpri.SelectedItem.ToString();
switch (value)
{
case "河南":
this.comcity.Items.Clear();
this.comcity.Items.AddRange(henancity);
this.comcity.SelectedIndex = ;
break;
case "河北":
this.comcity.Items.Clear();
this.comcity.Items.AddRange(hebeicity);
this.comcity.SelectedIndex = ;
break;
case "西藏":
this.comcity.Items.Clear();
this.comcity.Items.AddRange(xizangcity);
this.comcity.SelectedIndex = ;
break;
default:
break;
} }
private void comcity_SelectedIndexChanged(object sender, EventArgs e)
{
//int index = this.comcity.SelectedIndex;
#region MyRegion
object text = this.comcity.SelectedItem;
string priv =this.conpri.SelectedItem.ToString();
switch (priv)
{
case "河南":
if (text.Equals("郑州"))
{
this.comarea.Items.Clear();
this.comarea.Items.AddRange(zhengzhouarea);
this.comarea.SelectedIndex = ;
}
else if (text.Equals("洛阳"))
{
this.comarea.Items.Clear();
this.comarea.Items.AddRange(luoyangarea);
this.comarea.SelectedIndex = ;
}
else if (text.Equals("新乡"))
{
this.comarea.Items.Clear();
this.comarea.Items.AddRange(xinxiangarea);
this.comarea.SelectedIndex = ;
}
break;
case "河北":
if (text.Equals( "北京"))
{
this.comarea.Items.Clear();
this.comarea.Items.AddRange(beijingarea);
this.comarea.SelectedIndex = ;
}
else if (text.Equals("石家庄"))
{
this.comarea.Items.Clear();
this.comarea.Items.AddRange(shijiazhuangarea);
this.comarea.SelectedIndex = ;
}
else if (text.Equals("张家口"))
{
this.comarea.Items.Clear();
this.comarea.Items.AddRange(zhangjiakouarea);
this.comarea.SelectedIndex = ;
}
else if (text.Equals("邯郸"))
{
this.comarea.Items.Clear();
this.comarea.Items.AddRange(handanarea);
this.comarea.SelectedIndex = ;
}
break;
case "西藏":
this.comarea.Items.Clear();
this.comarea.Items.AddRange(lasaarea);
this.comarea.SelectedIndex = ;
break;
default:
break; #endregion
}
}
}

二.图片的翻页

由于在用文件这个方法时,感觉很是陌生吧,所以感觉这个也是蛮重要的啦,但是总感觉程序看起来也是蛮简单的,总是让自己写起来却不能独立完成啦,下面就把这个的思想在总结一下,希望下次我再用到这个方法啦能够和他成为好朋友似的,顺利的完成啦,下面就以图片的翻页为例写个程序吧,如下代码所示:

public partial class btnnext : Form
{
public btnnext()
{
InitializeComponent();
}
private void btnnext_Load(object sender, EventArgs e)
{
string[] path = Directory.GetFiles(@"I:\练习项目\11月27日\01radiocheckbox\img"); //启动项目时间可以加载一张图片。
this.pictureBox1.Image = Image.FromFile(path[]); //这里设置为默认的第一张图片
}
int i = ;
private void btnone_Click(object sender, EventArgs e)
{
string[] path = Directory.GetFiles(@"I:\练习项目\11月27日\01radiocheckbox\img"); //获取图片索引
if (i == )
{
this.pictureBox1.Image = Image.FromFile(path[path.Length - ]);
i = path.Length - ;
}
else
{
i--;
this.pictureBox1.Image = Image.FromFile(path[i]);
}
}
private void button2_Click(object sender, EventArgs e)
{
string[] path = Directory.GetFiles(@"I:\练习项目\11月27日\01radiocheckbox\img"); //获取图片索引存放在数组里面
//i++;
//this.pictureBox1.Image = Image.FromFile(path[0]); 本应该这样,但是由于在最后一张图片时间下一张要回到第一张来,
//所以判断一下是否为第一张然后在输出。
if (i.Equals(path.Length-))
{
i = ;
this.pictureBox1.Image = Image.FromFile(path[]); //当为第一张时间,点击按钮,则应该为上一张,
//而上一张为最后一张,即从索引值获取最后一张照片
}
else
{
i++;
this.pictureBox1.Image = Image.FromFile(path[i]);
}
}
}

三.用Timer控件显示图片

说起来Timer控件,感觉好玩,图片可以自动播放,只需要改变一下Interval,设置其自动播放的时间,然后把Enabled设置为true,在这里一般默认为false,设置后后即可,在程序中设置图片可以是顺序显示也可以是倒序显示额,具体的和上面上一张和下一张图片的显示类似,实现其代码如下:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string[] path = Directory.GetFiles(@"I:\练习项目\11月27日\01radiocheckbox\img");
private void Form1_Load(object sender, EventArgs e)
{
this.pictureBox1.Image = Image.FromFile(path[]);
}
int i = ;
private void timer1_Tick(object sender, EventArgs e)
{
#region 图片倒叙显示
//if (i.Equals(0))
//{
// this.pictureBox1.Image = Image.FromFile(path[path.Length - 1]);
// i = path.Length - 1;
//}
//else
//{
// this.pictureBox1.Image = Image.FromFile(path[i - 1]);
// i--;
//}
#endregion #region 图片顺序排列
i++;
if (i.Equals(path.Length))
{
//i = 0;
this.pictureBox1.Image = Image.FromFile(path[]);
}
else
{
this.pictureBox1.Image = Image.FromFile(path[i]);
}
#endregion
}
}

好啦,感觉今天只是把前几天学习的在练习下的啦,重复学习可能有新的收获额,我还要继续努力啦,感觉熟练才是最根本的。

使用C#语言实现一些功能的更多相关文章

  1. C语言:多功能计算器程序说明书

    好家伙,3000字终于写完了 一.题目:多功能科学计算器 二.内容: (1)概述或引言 开发环境为Visual C++ 目前已实现的功能: (1)解二元一次方程.一元二次方程 (2)进行矩阵相加.相减 ...

  2. C语言的split功能

    其它高级语言都有字符串的split功能,但C没有系统自带的,只能自己写一个了. void c_split(char *src, const char *separator, int maxlen, c ...

  3. C语言:多功能计算器 (矩阵相乘)

    好家伙,实现矩阵相乘功能 代码如下: void fifth()//矩阵的相乘// { int a[100][100],b[100][100]; int d,e,f,h,j,k,t; double su ...

  4. C语言:多功能计算器

    好家伙,这个东西有点折磨 这是一个多功能计算器 #include<stdio.h> #include<math.h> #include<windows.h> voi ...

  5. c语言实现wc功能

    本随笔对网站http://blog.chinaunix.net/uid-22566367-id-381958.html有所借鉴 #include <stdio.h> #define BEG ...

  6. C++语言运算符的功能、优先级和结合性

    优先级 运算符 名称或含义 使用形式 结合方向 说明 1 [] 数组下标 数组名[常量表达式] 左到右   () 圆括号 (表达式)/函数名(形参表)   . 成员选择(对象) 对象.成员名   -& ...

  7. python利用有道翻译实现“语言翻译器”的功能

    import urllib.request import urllib.parse import json while True: content = input('请输入需要翻译的内容(退出输入Q) ...

  8. Go语言的网络功能太强了,这么多项目。。。

    Centrifugo 是一个用 Golang 实现的基于 Websocket 或者 SockJS 的实时通信平台.https://www.oschina.net/p/centrifugalrpcx是一 ...

  9. 在Rust中使用C语言的库功能

    主要是了解unsafe{}语法块的作用. #[repr(C)] #[derive(Copy, Clone)] #[derive(Debug)] struct Complex { re: f32, im ...

随机推荐

  1. ref和out的使用与区别【转】

    http://www.cnblogs.com/sjrhero/articles/1922902.html out的使用 ———————————————————————————————————————— ...

  2. iOS网络NSURLSession使用详解

    一.整体介绍 NSURLSession在2013年随着iOS7的发布一起面世,苹果对它的定位是作为NSURLConnection的替代者,然后逐步将NSURLConnection退出历史舞台.现在使用 ...

  3. enter快捷键盘

    protected override bool ProcessDialogKey(Keys keyData) { #region PageDown if (keyData == Keys.Enter) ...

  4. [小技巧]diff的文件夹忽略使用方式

    当我们比较两个文件夹时经常需要忽略.svn或者.git,那么如下 diff -r -x ".git" -x "*.ko" -x "*.o" ...

  5. (转)Linux下PS命令详解

    (转)Linux下PS命令详解 整理自:http://blog.chinaunix.net/space.php?uid=20564848&do=blog&id=74654 要对系统中进 ...

  6. Quartz 与 Spring集成

    http://www.cnblogs.com/pigwing/archive/2011/07/12/2104002.html http://blog.arganzheng.me/posts/quart ...

  7. 数据结构——算法之(043)(c++各种排序算法实现)

    [申明:本文仅限于自我归纳总结和相互交流,有纰漏还望各位指出. 联系邮箱:Mr_chenping@163.com] 题目: c++ 各种排序算法实现 题目分析: 详细排序原理參考相关算法书籍 算法实现 ...

  8. C# 关于JArray和JObject封装JSON对象

    直入主题,不废话... 1.JObject:基本的json对象 /// <summary> /// Gets the j object. /// </summary> /// ...

  9. 公司内网成功实现WSUS在不连外网的条件下更新补丁包!

    微软的WSUS的命令行很有帮助! 为了便于管理,WSUS服务器中提供了一个命令行工具WSUSUtil.exe,你可以使用它完成一些在WSUS管理控制台中不能进行的任务,例如导入导出数据等等.WSUSU ...

  10. 使用explain分析sql语句

    sql语句优化 : sql语句的时间花在哪儿? 答: 等待时间 , 执行时间. 这两个时间并非孤立的, 如果单条语句执行的快了,对其他语句的锁定的也就少了. 所以,我们来分析如何降低执行时间. : s ...