구성 요소를 닫고 싶은 클래스가 있습니다. 다음 코드를 기반으로 작동 시키려고합니다.구성 요소 - 하위 클래스 이벤트 C#
문제는 속성 브라우저에서 속성을 편집하고 볼 수 있다는 것입니다. & 테스트 이벤트를 볼 수는 있지만 속성 브라우저에서 채울 수는 없습니다. 코드.
어떻게이 문제를 해결할 수 있습니까? 당신은 비주얼 스튜디오 속성 편집기에서 편집 할 수 있도록
namespace TestComponents
{
public partial class Test: Component
{
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public SubClass SubClass { get; set; }
public Test()
{
InitializeComponent();
SubClass = new SubClass();
}
}
public delegate void TestEventHandler(Object sender, TestEventArgs e);
public class TestEventArgs: EventArgs
{
public Boolean Test { get; set; }
public TestEventArgs(Boolean ATest): base()
{
Test = ATest;
}
}
[TypeConverterAttribute(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class SubClass
{
public Boolean TestProperty { get; set; }
public event TestEventHandler TestEvent;
protected virtual void OnTestEvent(TestEventArgs e)
{
if (TestEvent != null)
TestEvent(this, e);
}
}
}
하지만 하위 클래스가 아닌 구성 요소 내부에서 직접 이벤트를 선언 할 경우 Visual Studio에서 편집기 속성을 선언하지 않고이 이벤트의 코드를 자동으로 만듭니다. – Ivn
혼란 스럽습니다. 귀하의 코드에 따르면 귀하의 이벤트는 하위 클래스 안에 있습니까? 속성 그리드에서 속성을 표시하는 개체는 무엇입니까? 테스트 또는 하위 클래스? 스크린 샷이 도움이 될 수 있습니다. – Gareth
http://i.stack.imgur.com/utxtR.png – Ivn