3
我有我的本地化屬性,如問題:如何刷新本地化的屬性在PropertyGrid中
public class LocalizedDisplayNameAttribute : DisplayNameAttribute
{
public LocalizedDisplayNameAttribute(string resourceId)
: base(GetMessageFromResource(resourceId))
{ }
private static string GetMessageFromResource(string resourceId)
{
var propertyInfo = typeof(Lockit).GetProperty(resourceId, BindingFlags.Static | BindingFlags.Public);
return (string)propertyInfo.GetValue(null, null);
}
}
當我使用屬性與此屬性它在PropertyGrid中的局部,但是當我改變當前CultureInfo它不不會刷新,即使我再次創建此PropertyGrid。我已經嘗試通過手動調用屬性:
foreach (PropertyInfo propertyInfo in myPropertiesInfoTab)
{
object[] custom_attributes = propertyInfo.GetCustomAttributes(false);
}
屬性構造函數被調用,而新創建的PropertyGrid中仍然有舊文化的顯示名稱(總是像第一次創建相同的值)的屬性。
它在我重新啓動應用程序時起作用,但我不想這樣做。有沒有解決方法?