【发布时间】:2012-10-04 01:23:51
【问题描述】:
我的班级有两个属性:MyCountry 和 MyCity。我将此类设置为属性网格的源对象。我想在选择一个国家时加载我组合的城市。例如,我有 2 个国家/地区数据:
Country1
Country2
对于 Country1,我有(城市数据)
City11
City12
City13
对于 Country2,我有(城市数据)
city21
City22
City23
当我在 propertygrid 中更改选择国家项目时,我想在城市项目中加载它的城市。 this mean, when select Country1, display City11,City12,City13 in City item and when select Country2 Display City21,Cityy22,City23 在城市项目中。
我该怎么办?
我的班级是:
public class KeywordProperties
{
[TypeConverter(typeof(CountryLocationConvertor))]
public string MyCountry { get; set; }
[TypeConverter(typeof(CityLocationConvertor))]
public string MyCity { get; set; }
}
我使用下面的类来加载国家数据以组合显示:
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
HumanRoles Db = new HumanRoles();
List<LocationsFieldSet> Items = new List<LocationsFieldSet>();
Items = Db.LoadLocations(0);
string[] LocationItems = new string[Items.Count];
int count = 0;
foreach (LocationsFieldSet Item in Items)
{
LocationItems[count] = Item.Title;
count++;
}
return new StandardValuesCollection(LocationItems);
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
}
【问题讨论】:
标签: c# propertygrid