Visually inheriting from abstract/generic UserControls in CF

S

Scott Gifford

Hello,

I'm using Visual Studio 2008 Beta 2 and .NET Compact Framework 2.0.

I have a UserControl component for editing rules. Right now I'm using
a class which inherits from UserControl and uses a generic type to
hold the type of rule that is being edited. Then derived types
specify the generic type to say what type of rule they can edit. I
like this design because it lets me put some common code in the parent
class, and if I try to pass the wrong sort of rule to a UI component I
find out at compile-time. Roughly it looks like this:

public abstract class Rule { ... }

public abstract class GenericRuleControl<T> : UserControl
where T : Rule
{
public abstract void SetRule(T rule);
public abstract T GetRule();
// Common code for all inherited types
}

public class TimeRule : Rule { ... }

public class TimeRuleControl : GenericRuleControl<TimeRule>
{
// ...
}

I coded this all up and it worked great. Unfortunately the first time
I closed and re-opened the project in Visual Studio it stopped
working. I found out this is because abstract or generic base classes
aren't supported in the designer. I managed to find some instructions
for making it work, here:

http://www.urbanpotato.net/default.aspx/document/2001

That code works fine in a desktop project, but in a Compact Framework
project I get these errors:

Error 2 - The type or namespace name 'TypeDescriptionProvider' could
not be found (are you missing a using directive or an assembly
reference?)

Error 5 - The type or namespace name 'TypeDescriptionProviderAttribute'
could not be found (are you missing a using directive or an assembly
reference?)

And indeed, the documentation for TypeDescriptionProvider says that it
is not supported on the Compact Framework.

Does anybody have any suggestions for making this work in the Compact
Framework, or doing something roughly equivalent?

Thanks!

----Scott.
 

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

Top