읽기 전용 인 사용자 정의 UityPeeditor의 ELIPSIS를 어떻게 제거합니까?

StackOverflow https://stackoverflow.com/questions/616671

  •  03-07-2019
  •  | 
  •  

문제

속성 그리드에서 같은 유형의 필드가 있습니다. 그러나 하나는 읽기 전용이고 다른 하나는 편집 가능합니다.

이 두 필드는 모두 사용자 정의 유형이므로 사용자 정의 UityPeeditor가있어 Elipsis ([...]) 버튼을 필드에 넣습니다.

[
     CategoryAttribute("5 - Wind"),
     DisplayName("Factored Area"),
     Description("The factored area for the segment."),
     EditorAttribute(typeof(umConversionTypeEditor), typeof(UITypeEditor)),
     TypeConverter(typeof(umConversionTypeConverter)),
     ReadOnly(true)
]
public FactoredAreaClass FactoredArea { ... }

[
     CategoryAttribute("5 - Wind"),
     DisplayName("Factored Area Modifier"),
     Description("The factored area modifier."),
     EditorAttribute(typeof(umConversionTypeEditor), typeof(UITypeEditor)),
     TypeConverter(typeof(umConversionTypeConverter))
]
public FactoredAreaClass FactoredAreaMod { ... }

이 예에서는 팩토리 레미오드를 편집 할 수 있지만 둘 다 ELIPSIS가있어 사용자와 큰 혼란을 줄 수 있습니다. 그것을 끄는 방법 ??

도움이 되었습니까?

해결책

사용 준비 적 기인하다. 런타임 사용을 위해 읽기/쓰기를 유지하면서 설계 시간 읽기 전용으로 표시됩니다.

또한, 당신은 적용해야합니다 편집자 속성보다는 유형에 속합니다. 해당 부동산을 편집 할 수없는 경우 재산에 적용 할 수있는 이익이 없습니다.

다른 팁

Jeff Yates 덕분에 나는 대체 솔루션을 생각해 냈습니다. 내가 그것을 해결 한 방법은 다음과 같습니다 ...

가장 큰 문제는 편집장이 실제로 인공 호에 할당되었다는 것입니다. 편집기 속성이 할당되어 있음을 보여주기 위해 원시 예제에 넣었습니다.

[
    CategoryAttribute("5 - Wind"),
    DisplayName("Factored Area"),
    Description("The factored area for the segment."),
    EditorAttribute(typeof(UITypeEditor), typeof(UITypeEditor)), // RESET THE UITYPEEDITOR to "nothing"
    ReadOnly(true)
]
public FactoredAreaClass FactoredArea { ... }

[
    CategoryAttribute("5 - Wind"),
    DisplayName("Factored Area Modifier"),
    Description("The factored area modifier."),
    // the EditorAttribute and TypeConverter are part of FactoredAreaClass
]
public FactoredAreaClass FactoredAreaMod { ... }

트릭은 경계 특성이 준비된 경우 모달 스타일을 사용하지 않는 것입니다. 운 좋게도 컨텍스트는 GetEditStyle 방법으로 제공됩니다. 간단한 코드는 작업을 수행합니다.

public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
  return context.PropertyDescriptor.IsReadOnly 
          ? UITypeEditorEditStyle.None 
          : UITypeEditorEditStyle.Modal;       
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top