2009-03-05 3 views
1

내 속성 표에 동일한 유형의 두 개의 필드가 있습니다. 그러나 하나는 읽기 전용이고 다른 하나는 편집 가능합니다.읽기 전용 인 사용자 정의 UITypeEditor에 대한 엘립시는 어떻게 제거합니까?

이러한 필드는 모두 사용자 지정 형식이므로 필드에 elipsis ([...]) 단추를 넣는 사용자 지정 UITypeEditor가 있습니다. 이 예에서

[ 
    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 { ... } 

는 FactoredAreaMod 편집 할 수 있습니다,하지만 둘 다 사용자와 큰 혼란을 야기 할 elipsis을 보유하고 있습니다. 그걸 끄는 어떤 방법?

답변

1

ReadOnly 속성을 사용하십시오. 런타임 사용을 위해 읽기/쓰기로 유지하면서 디자인 타임으로 읽기 전용으로 표시합니다.

또한 속성이 아닌 유형에 Editor 특성을 적용해야합니다. 속성을 편집 가능하게하지 않으려면 속성에 적용 할 필요가 없습니다.

+0

예에서를, 내가 읽기 전용 속성을 사용했다는 것을 알 수 있습니다. 그리고 이것은 런타임 동안 속성 표 내에서 사용하기위한 것입니다. 그래서 나는 단지 운이 좋다? – Jerry

+0

이제 알 수 있습니다. 그러나 EditorAttribute 선언 우선 순위가 의심됩니다. 해당 속성을 FactoredAreaMod 유형에 적용하거나 실제로 편집해야하는 속성에만 적용해야합니다. –

1

Jeff Yates 덕분에 다른 해결책을 찾았습니다. 여기 내가 어떻게 해결 했는가 ...

가장 큰 문제는 실제로 EditorAttribute가 FactoredAreaClass에 할당되었다는 것입니다. 나는 편집자 속성이 할당되었음을 보여주기 위해 원시 예제에 넣었다.

[ 
    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 { ... } 
0

경계 된 속성이 읽기 전용 일 때 트릭이 모달 스타일을 사용하지 않습니다. 다행스럽게도 GetEditStyle 메서드에서 컨텍스트를 제공합니다. 간단한 코드는 작업을 수행합니다

public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) 
{ 
    return context.PropertyDescriptor.IsReadOnly 
      ? UITypeEditorEditStyle.None 
      : UITypeEditorEditStyle.Modal;  
} 
관련 문제