Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Component - Subclass event c#

$
0
0

I have a class what I would like to close into a component. I try to make it work, based on the following code,

The issue is, that the properties are editable and viewable in the property browser & the TestEvent is viewable but it cannot be filled form the property browser, just from the code.

How can I solve this anomaly?

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);
    }
  }
}


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>