사용자 지정을 위해 PropertyGrid에서 디자인 타임과 런타임 모두에 사용되는 ICustomTypeDescriptor를 구현하는 클래스 (컨트롤)가 있습니다. 디자인 타임에 다른 속성을 노출해야합니다 (예 : width
, height
등의 컨트롤 속성). 프로그램에서 PropertyGrid를 사용하여 해당 컨트롤의 다른 속성을 변경하면 런타임에 속성을 노출해야합니다.컨트롤이 디자인 타임에 있는지 여부를 확인하는 방법?
class MyControl : UserControl, ICustomTypeDescriptor
{
//Some code..
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
return GetProperties();
}
public PropertyDescriptorCollection GetProperties()
{
//I need to do something like this:
if (designTime)
{ //Expose standart controls properties
return TypeDescriptor.GetProperties(this, true);
}
else
{
//Forming a custom property descriptor collection
PropertyDescriptorCollection pdc = new PropertyDescriptorCollection(null);
//Some code..
return pdc;
}
}
}
는 C#에서 디자인 타임 플래그 아날로그가 있습니까 :
내 코드는 같다? 조건부 컴파일을 사용하는 것이 더 좋은가?
wpf 또는 winform에 대해 이야기하고 있습니까? –
가능한 중복 * [Visual Studio 디자이너가 .NET 코드를 실행하는지 확인하는 방법] (http://stackoverflow.com/questions/73515/how-to-tell-if-net-code-is-being- run-by-visual-studio-designer) *. –