custom server control: problem with designer

  • Thread starter Jürgen Müller
  • Start date
J

Jürgen Müller

Hi, all.

I'm having a strange problem while writing custom server control.
The control works fine so far, but I wanted to add some features which
support the developer while using the control in the Visual Studio designer.
Therefore I've added a designer which extends ContainerControlDesigner...see
code fragment below.

Problem:
Sometimes the cast MyComponent c = (MyComponent)base.Component will throw an
exception - and sometimes not. I haven't found a reason for this. The type of
base.Component is MyComponent. I've checked this in the debugger. Even Visual
Studio shows me all properties of this type during debugging.
I've modified the code and read the value of c.MyProperty via reflection -
and it works...

Any ideas what might be wrong or what happens here?

Any help appreciated.

Reagrds
Jürgen
Code fragment:

public class MyDesigner : ContainerControlDesigner
{

public override string FrameCaption {
get
{
MyComponent c = (MyComponent)base.Component;

return "MyComponent - " + c.MyProperty;
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top