browsable

C# Dynamic Attribute Arguments

安稳与你 提交于 2019-11-29 15:12:19
Is there a way to do the following? I see that the Attribute Arguments must be a constant expression, so how would I work around this? If I dont want to load some properties into a datagridview using binding, whats the next best alternative? class TestObj { private bool isBrowsable = false; [Browsable(isBrowsable)] public string String1 { get { return "Foo"; } } [Browsable(isBrowsable)] public string String2 { get { return "Baz"; } } } You can provide dynamic custom type information at runtime by implementing the ICustomTypeDescriptor interface - but this is quite a bit of work at not nearly

C# Dynamic Attribute Arguments

亡梦爱人 提交于 2019-11-28 08:47:48
问题 Is there a way to do the following? I see that the Attribute Arguments must be a constant expression, so how would I work around this? If I dont want to load some properties into a datagridview using binding, whats the next best alternative? class TestObj { private bool isBrowsable = false; [Browsable(isBrowsable)] public string String1 { get { return "Foo"; } } [Browsable(isBrowsable)] public string String2 { get { return "Baz"; } } } 回答1: You can provide dynamic custom type information at