首先在地图上

 #region 选择城市
/// <summary>
/// 点击字母事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void item_Click(object sender, EventArgs e)
{
LinkLabel lbl = sender as LinkLabel;
lbl.Font = new Font(new FontFamily("宋体"), 10, FontStyle.Bold);
foreach (Control item in pan_CityTitle.Controls)
{
if (item is LinkLabel && item != lbl)
item.Font = new Font(new FontFamily("宋体"), 10, FontStyle.Regular);
}
flowLayoutPanel.Controls.Clear();
CreatCheckCityControl(lbl.Tag != null ? lbl.Tag.ToString() : string.Empty);
} /// <summary>
/// 绘制城市控件
/// </summary>
private void CreatCheckCityControl(string lettey)
{
if (lettey == string.Empty)
{
List<FlyCity> list = dicList["RM"];
CreatControl(list);
}
else
{
for (int i = 0; i < lettey.Length; i++)
{
string temp = lettey.Substring(i, 1);
if (!dicList.Keys.Contains(temp))
{
continue;
}
List<FlyCity> list = dicList[temp];
CreatControl(list);
}
}
}
private void CreatControl(List<FlyCity> list)
{
foreach (FlyCity fly in list)
{
Button button = new Button()
{
Text = fly.CityName,
Tag = fly,
Width = 76,
Height = 25,
ForeColor = Color.FromArgb(89, 89, 89),
FlatStyle = FlatStyle.Flat,
};
button.FlatAppearance.BorderColor = Color.White;
button.Click += new EventHandler(button_Click);
button.MouseHover += new EventHandler(button_MouseHover);
button.MouseLeave += new EventHandler(button_MouseLeave);
flowLayoutPanel.Controls.Add(button);
}
}
/// <summary>
/// 隐藏控件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void FlyReserveForm_MouseUp(object sender, MouseEventArgs e)
{
if (!pan_City.Capture)
{
this.pan_City.Visible = false;
}
if (!calendar.Capture)
{
this.calendar.Hide();
}
}
/// <summary>
/// 点击选择目的地
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void btnToCity_Click(object sender, EventArgs e)
{
sType = 1;
pan_City.Visible = true;
pan_City.Location = new Point(446, 100);
}
/// <summary>
/// 点击选择出发城市
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void btnFromCity_Click(object sender, EventArgs e)
{
sType = 0;
pan_City.Visible = true;
pan_City.Location = new Point(133, 100);
}
/// <summary>
/// 从xml获取城市列表
/// </summary>
private void LoadCityArray()
{
List<FlyCity> list = new List<FlyCity>();
XmlHelper help = new XmlHelper(Environment.CurrentDirectory + "\\arrays.xml");
DataSet ds = help.GetData("resources");
foreach (DataRow item in ds.Tables[0].Rows)
{
FlyCity fly = new FlyCity();
string city = item[0].ToString().Substring(0, item[0].ToString().IndexOf(","));
string cityCode = item[0].ToString().Substring(item[0].ToString().IndexOf(",") + 1, item[0].ToString().Length - item[0].ToString().IndexOf(",") -1);
fly.CityName = city;
fly.CityCode = cityCode;
list.Add(fly);
}
dicList = ChineseConvert.InsertDic(list);
} void button_Click(object sender, EventArgs e)
{
if ((sender as Button).Tag == null)
return;
FlyCity fly = (sender as Button).Tag as FlyCity;
if (sType == 0)
{
lblFromCity.Text = fly.CityName;
lblFromCity.Tag = fly;
}
else
{
lblToCity.Text = fly.CityName;
lblToCity.Tag = fly;
}
pan_City.Visible = false;
} private void Pan_TitleClick()
{
foreach (Control item in pan_CityTitle.Controls)
{
if(item is LinkLabel)
item.Click += new EventHandler(item_Click);
}
} void button_MouseLeave(object sender, EventArgs e)
{
(sender as Button).BackColor = Color.White;
(sender as Button).ForeColor = Color.FromArgb(89, 89, 89);
} void button_MouseHover(object sender, EventArgs e)
{
(sender as Button).BackColor = Color.FromArgb(41, 100, 180);
(sender as Button).ForeColor = Color.White;
}
#endregion

版权声明:本文博主原创文章。博客,未经同意不得转载。

winform 实现选择的城市名单的更多相关文章

  1. (转)在WinForm中选择本地文件

    相信很多朋友在日常的编程中总会遇到各钟各样的问题,关于在WinForm中选择本地文件就是很多朋友们都认为很难的一个学习.net的难点, 在WebForm中提供了FileUpload控件来供我们选择本地 ...

  2. 【.Net】在WinForm中选择本地文件

    相信很多朋友在日常的编程中总会遇到各钟各样的问题,关于在WinForm中选择本地文件就是很多朋友们都认为很难的一个学习.net的难点, 在WebForm中提供了FileUpload控件来供我们选择本地 ...

  3. winform中选择文件获取路径

    private void button1_Click(object sender, EventArgs e) { //此时弹出一个可以选择文件的窗体 OpenFileDialog fileDialog ...

  4. WPF与Winform的选择

    最近公司计划对ERP系统全面升级,现有的ERP是简单的bs架构系统打算改版成cs.平时如自己写一些工具,小应用都是用winform就足够.但是界面总是很难看,据了解WPF在这一方面会强一些.因为之前对 ...

  5. winform 实现选择文件和选择文件夹对话框

    //选择文件,点击[浏览],选择文件 private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileD ...

  6. C# winform中 选择文件和保存文件

    转载自https://blog.csdn.net/qq_31788297/article/details/62047952 我们在使用桌面软件的时候经常会使用到选择文件并打开和另存为等的窗口,这样方便 ...

  7. C# WinForm TreeView选择父节点子节点全选

    //设置标志,防止死循环 bool check = false; public void TV_AfterCheck(object sender, TreeViewEventArgs e) { if ...

  8. 【代码笔记】iOS-先选择城市,然后,跳转Tabbar

    一,效果图. 二,工程图. 三,代码. ChooseCityViewController.h #import <UIKit/UIKit.h> @interface ChooseCityVi ...

  9. 仿51job.com城市选择框特效

    650) this.width=650;" border="0" alt="" src="http://img1.51cto.com/att ...

随机推荐

  1. 编译命令行终端 swift

    So, this is where swift lives, after you've installed XCode 6 Beta: /Applications/Xcode6-Beta.app/Co ...

  2. C# winForm里窗体嵌套

    ShowAllPage sAllPage = new ShowAllPage();            sAllPage.FormBorderStyle = FormBorderStyle.None ...

  3. POJ 1915 Knight Moves(BFS+STL)

     Knight Moves Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 20913   Accepted: 9702 ...

  4. 证明 poj 1014 模优化修剪,部分递归 有错误

    这个问题是存在做.我发现即使是可行的一个问题,但不一定正确. 大部分数据疲软,因为主题. id=1014">poj 1014 Dividing 题目大意:有6堆石头,权重分别为1 2 ...

  5. Android SharedPreferences复杂的存储

    我们知道SharedPreferences简单类型的数据.比如.String.int等. 假设想用SharedPreferences存取更复杂的数据类型(类.图像等),就须要对这些数据进行编码. 我们 ...

  6. CFormView动态调整对话框的尺寸和调整比例控制的部署

    基于单个文件CFormView动态调整对话框的尺寸和调整比例控制的部署 假设你正在开发一个程序基于单个文件,使用CFormView基类来实现多种形式展示,那么,这个文件可能会给你一点帮助. 一.实现对 ...

  7. HDU 3874 离线段树

    在所有数字的统计范围,,对于重复统计只有一次 离线段树算法 排序终点坐标.然后再扫,反复交锋.把之前插入树行被删除 #include "stdio.h" #include &quo ...

  8. oracle Constraint[相似 constraint使用方法总结 I]

    约束简单介绍 约束用于确保数据库数据满足特定的商业逻辑或者企业规则,假设定义了约束,而且数据不符 合约束,那么DML操作(INSERT.UPDATE.DELETE)将不能成功运行.约束包含NOT NU ...

  9. rabbitmq技术的一些感悟(一)

    Rabbitmq 初识rabbitmq RabbitMQ是流行的开源消息队列系统,用erlang语言开发.RabbitMQ是AMQP(高级消息队列协议)的标准实现.假设不熟悉AMQP,直接看Rabbi ...

  10. 【2014】【】辛星【php】【秋】【1】php构建开发环境

    **************************什么是开发环境*********************** 1.我们学习PHP,是使用它来做web用的,通俗理解,就是做站点. 2.站点的执行须要 ...