首先在地图上

 #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. CloudFoundry 中的GoRouter性能測试

    之前一直感觉CloudFoundry的GoRouter的性能不靠谱,或者我们的CloudFoundry 部署架构存在问题,想着进行一些压力測试,可是一直苦于没有压力測试的工具.上一周,部门须要出一个測 ...

  2. Orleans:NET的Actor模型

    .NET的Actor模型:Orleans   Orleans是微软推出的类似Scala Akka的Actor模型,Orleans是一个建立在.NET之上的,设计的目标是为了方便程序员开发需要大规模扩展 ...

  3. vs2012 网站无法使用自定义服务器的解决方法

    我已经习惯新建一个Asp.net网站时把它挂载在IIS下调试运行,在使用Visual Studio 2012后,新建网站配置启动选项时,自定义服务器居然不可用 原来是Visual Studio 201 ...

  4. HDU 2063:过山车(偶匹配,匈牙利算法)

    过山车 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  5. 【Java基础】System.arraycopy()的使用详解

    由于在Java中System.arraycopy()方法在一维数组和二维数组中的表现不同,所以做了一个测试 public static void main(String[] args) { int[] ...

  6. ubuntu 下搭建apache+python的运行环境

    ubuntu下怎么搭建apache+python运行环境,可以参考http://www.01happy.com/ubuntu-apache-mod-python/ ,这里只是简单的记录下步骤,本文主要 ...

  7. 自己主动机串标:Directed Acyclic Word Graph

    trie -- suffix tree -- suffix automa 有这么几个情况: 用户输入即时响应AJAX搜索框, 显示候选名单. 搜索引擎keyword统计数量. 后缀树(Suffix T ...

  8. Android4.2.2由于越来越多的物理按键(frameworks)

    当我们改变frameworks之后可能: make: *** [out/target/common/obj/PACKAGING/checkapi-current-timestamp] 错误 38 解决 ...

  9. 理解JNDI中 java:comp/env/jdbc/datasource 与 jdbc/datasource 的不同之处(转)

    在描述JNDI,例如获得数据源时,JNDI地址有两种写法,例如同是  jdbc/testDS 数据源: A:java:comp/env/jdbc/testDS B:jdbc/testDS   这两种写 ...

  10. ReferenceTypeDemo

    对象a作为参数argument在方法中使用时,如果argument在方法中赋予另一个对象的地址,则之后方法中对参数argument的操作,都不会影响到对象a. 方法中参数argument如果是对象,a ...