0

我在 windowsform 应用程序中有三个列表框。我想在各自的三个列表框中显示国家、州、城市。但应根据所选国家和城市类似地显示州。

现在代码对于两个三个国家来说似乎不是问题,但是如果我考虑一个实际情况,记住世界上所有国家及其相应的州和城市会怎样。

实现这一点的最佳方法是什么?

更新---我实际上想问什么数据结构最适合这个?
一个 3d 锯齿状阵列可以正常工作 .nO 吗?还是有更好的方法来做到这一点?我不知道该怎么做。任何人都可以编码吗?

4

2 回答 2

0

Generally a top down hierarchy is applied.

  1. Bind the countries list (nothing else)
  2. On country selection, bind/rebind the states list filtered for the country & clear the city list.
  3. Finally on a state selection, bind/rebind the city dropdown.
于 2012-06-28T14:41:58.957 回答
0

将所有国家加载到第一个列表中。当用户选择一个国家时,清除州/普罗维登斯和城市列表框。加载所选州/普罗维登斯的城市。when a state/providence is selected load the cities.

附加选项:

  1. 让用户输入他们的邮政编码(假设有国际代码)并根据代码查找城市。
  2. 允许用户将其输入到自由格式的文本框中,而不是预定义的列表中。
  3. 要求用户在使用匹配选项填充列表之前输入前 N 个字符。
于 2012-06-28T14:21:46.260 回答