📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace 国省市下拉条
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Hashtable hashtable = new Hashtable();
private void Form1_Load(object sender, EventArgs e)
{
String str = "2008-01-11 11:42:49.267";
String []str1 = str.Split(new Char[] { ' ', '-',' ','-',' ',' ',' ',':',' ',':',' ','.',' '});
MessageBox.Show(str1[0]+str1[1]+str1[2]+str1[3]+str1[4]);
Add add = new Add();
hashtable = add.Addhashtable();
FillcomboBox();
}
//添加国家
private void FillcomboBox()
{
String[] ww=GetItems(hashtable["0"].ToString());
for (int i = 0; i <ww.Length ;i++ )
{
this.comboBox1.Items.Add (ww[i].ToString());
}
}
//获取详细字段
private String[] GetItems(String aa)
{
int y=0;
for(int i=0;i<aa.Length ;i++)
{
if(aa[i].Equals(","))
{
y++;
}
}
String[] item=new string[y+1];
item=aa.Split(',');
return item;
}
//添加省
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//this.comboBox2.Text = "";
//this.comboBox3.Text = "";
//this.comboBox2.Items.Clear();
int a=this.comboBox1.SelectedIndex;
int b = this.comboBox1.SelectedIndex;
int c = this.comboBox2.SelectedIndex;
String[] ww = GetItems(hashtable["0_"+a].ToString());
this.comboBox2.Text = ww[0].ToString();
String[] ss = GetItems(hashtable["0_" + b + "_" + c].ToString());
this.comboBox3.Text = ww[0].ToString();
for (int i = 0; i < ww.Length; i++)
{
this.comboBox2.Items.Add(ww[i].ToString());
}
}
//添加市
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
//this.comboBox3.Text = "";
//this.comboBox3.Items.Clear();
int a = this.comboBox1.SelectedIndex;
int b = this.comboBox2.SelectedIndex;
String[] ww = GetItems(hashtable["0_" + a + "_" + b].ToString());
this.comboBox3.Text = ww[0].ToString();
for (int i = 0; i < ww.Length; i++)
{
this.comboBox3.Items.Add(ww[i].ToString());
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -